Jump to content


Photo

Removing the character and everything before it in it's first occurance?


  • Please log in to reply
1 reply to this topic

#1 dagnasty

dagnasty
  • Members
  • PipPipPip
  • Advanced Member
  • 66 posts

Posted 03 July 2006 - 07:05 PM

So let's say I have this string:

[Movies - Comedy] The Funny Movie [DVD]

and I want to remove first occurance of ] and everything before it, how would I go about doing it so that it leaves me

The Funny Movie [DVD]

?

strstr leaves the ] behind

#2 effigy

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

Posted 03 July 2006 - 07:19 PM

<?php
	$string = '[Movies - Comedy] The Funny Movie [DVD]';
	echo $string = preg_replace('/^[^]]+\]\s*/', '', $string);
?>

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