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); Link to comment https://forums.phpfreaks.com/topic/14256-simple-ereg_replace-help/ 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+\./ Link to comment https://forums.phpfreaks.com/topic/14256-simple-ereg_replace-help/#findComment-55993 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 Link to comment https://forums.phpfreaks.com/topic/14256-simple-ereg_replace-help/#findComment-56277 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 Link to comment https://forums.phpfreaks.com/topic/14256-simple-ereg_replace-help/#findComment-56303 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. Link to comment https://forums.phpfreaks.com/topic/14256-simple-ereg_replace-help/#findComment-56312 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 Link to comment https://forums.phpfreaks.com/topic/14256-simple-ereg_replace-help/#findComment-56789 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: /^.+\./ Link to comment https://forums.phpfreaks.com/topic/14256-simple-ereg_replace-help/#findComment-56818 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!!!! Link to comment https://forums.phpfreaks.com/topic/14256-simple-ereg_replace-help/#findComment-57637 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.