1

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

1
  • Artefacto means: post the code that failed. Commented Jul 15, 2010 at 8:03

1 Answer 1

4
$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);
Sign up to request clarification or add additional context in comments.

1 Comment

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!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.