[SOLVED] Need a regex to match anything between {{% and }}

Hi there
I need a regex to match any thing between {{% and }} that work with utf8 characters too.
for now im using '#{{%(\w|\s|\?|\.|\+|\*|\^|\-)*}}#u' but there are some special chars that i cant handle them, for example check this list of special character (84 KB)

thanks in advanced

Would you please help me?

thanks

Give the one below a try.

'#\{\{%.*?\}\}#su'

Please keep in mind that if you send over invalid UTF-8 sequence then the preg operation will fail as it first validate if it is correct. So if any of your strings contain invalid UTF-8 characters, that could be why it fails to return what your looking for.

Edit:
Also, if you have not tried it yet, when dealing with regex I can recommend RegexBuddy, a license is cheap, and it makes it easy to validate that the regex works as expected.

1 Like

thanks, solved

btw how can i edit the first post title? i want to append β€œ[SOLVED]” to it.

You can’t do that, but I can (just did it for you) :slight_smile: .

After a certain amount of hours, the post is uneditable for you.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.