Jump to content


Photo

Help with regex...fetching part from string


  • Please log in to reply
1 reply to this topic

#1 belick

belick
  • Members
  • PipPipPip
  • Advanced Member
  • 60 posts

Posted 24 July 2006 - 01:09 PM

I need to fetch part of a string that can be anyting. The roll is basic:
starting with " dbo." ending with ".(.*) " I think

botom line I need to fetch:  "dbo.AnyTableHere.AnyField" when "AnyTableHere" can be anything etc...


(CASE WHEN dbo.AnyTableHere.AnyField = 1 THEN dbo.T_Trucks.TruckName END)

thanks ahead!!!
<?="C"+"Y"+"T"+"N"+"E"+"T"+"."+"C"+"O"+"M";?>
Cytnet.com :-)

#2 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 24 July 2006 - 02:02 PM

<?php
	$string = '(CASE WHEN dbo.AnyTableHere.AnyField = 1 THEN dbo.T_Trucks.TruckName END)';
	preg_match_all('/dbo\.(.+?)\./', $string, $matches);
	array_shift($matches);
	echo '<pre>', print_r($matches, true), '</pre>';
?>

Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users