belick Posted July 11, 2006 Share Posted July 11, 2006 I need to take out anything that start with dbo.Table1. for example:dbo.Table1.Field1dbo.Table2.Field2dbo.Table2.Field2dbo.Table3.Field3need to be:Field1Field2Field2Field3$s = str_replace("dbo.(.*).", "", $string); Quote Link to comment Share on other sites More sharing options...
effigy Posted July 11, 2006 Share Posted July 11, 2006 str_replace is not regex. Try this with preg_replace: /^dbo\.Table\d+\./ Quote Link to comment Share on other sites More sharing options...
redarrow Posted July 11, 2006 Share Posted July 11, 2006 <?$string="dbo.Table1.Field1";$a=eregi_replace("dbo.Table1.", "", $string);echo $a;?>resultField1 Quote Link to comment Share on other sites More sharing options...
redarrow Posted July 11, 2006 Share Posted July 11, 2006 Also this way mate all throw all the table ok.<?//just chage $b=explode("",tablename);$b=array("dbo.Table1.Field1","dbo.Table2.Field2","dbo.Table3.Field3","dbo.Table4.Field4");while(list($k,$v)=each($b)) {$x=substr($v, 11);echo "<br>$x";}?>//out comeField1Field2Field3Field4 Quote Link to comment Share on other sites More sharing options...
effigy Posted July 11, 2006 Share Posted July 11, 2006 [quote author=redarrow link=topic=100147.msg395258#msg395258 date=1152635864]Also this way mate all throw all the table ok.[/quote]This is not as efficient or modular. Quote Link to comment Share on other sites More sharing options...
belick Posted July 12, 2006 Author Share Posted July 12, 2006 right, but the string is not somthing with "table" only it can be "dbo.(*.*).Field3".$string = 'dbo.Table3.Field3';$pattern = '/^dbo\.Table\d+\./';$replacement = '';echo preg_replace($pattern, $replacement, $string);bottom line, I need to get rid of anything before the field name.Thanks Quote Link to comment Share on other sites More sharing options...
effigy Posted July 12, 2006 Share Posted July 12, 2006 [quote author=belick link=topic=100147.msg395778#msg395778 date=1152718288]bottom line, I need to get rid of anything before the field name.[/quote]If it always starts with "dbo": /^dbo\.[^.]+\./If you want to remove everything before the last period: /^.+\./ Quote Link to comment Share on other sites More sharing options...
belick Posted July 13, 2006 Author Share Posted July 13, 2006 like always, effigy, you are the best!!!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.