tags:

views:

26

answers:

1

Hi,

how from this text get WORD and WORD2.

text tex asad t text [mycode]WORD[/mycode] tex asda [mycode]WORD2[/mycode] asdasdasd

I try using preg-match, but i fail

+4  A: 
$str = "text tex asad t text [mycode]WORD[/mycode] tex asda [mycode]WORD2[/mycode] asdasdasd";
preg_match_all("/\[mycode\](.*?)\[\/mycode\]/", $str, $preg);
print_r($preg);
marvin
few seconds before me :)
narcisradu
I don't know why everyone is so insistent on starting and ending their regexes with a forward slash..... you wouldn't have to escape it if you used something different!
Mark