Need little regex help

Hello everyone,

I am creating a template parser function that can recognise some tag like this

<wl:include param1="value1" param2="value2" param3="value3" />

currently I am using this regex to match…

$regex = '#<wl:include\ (([a-zA-Z0-9]*)=(.*))*\/>#iU';

it’s quite working but unfortunately it can’t read this tag

<wl:include param1="value1" param2="value2" param3="some tag with <br/> like this" />

it will only read until :

<wl:include param1="value1" param2="value2" param3="some tag with <br/>

How do I fix the regex… I am still learning regex so maybe I miss something…

try this one, didn’t test but should work

'#<wl:include\ (\w*)=(\'\")?([^\'\"]*))*(\'\")? \/>#iU'

in the param it checks for quotes and will end after the quotes

try add the end of line symbol $ ?

$regex = '#<wl:include\ (([a-zA-Z0-9]*)=(.*))*\/>$#iU';


Wow, what a quick reply :D

I’ve tried but unfortunately it doesn’t work


Thanks… I’ll try it later…

currently not on my working laptop :)

unfortunately adding $ still doesn’t solve it…

After some trial and error I think I’ve solve my problem. The regex I’ve made is like this:

$regex = '#<wl:include\ ([\w]*=[\"\'](.*)[\"\'])*[\ ]*\/>#iU';

Thanks for everybody’s help