junxiong
(Junxiong)
1
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…
gusnips
(Gustavo)
2
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
jpenguin
(Panupatc)
3
try add the end of line symbol $ ?
$regex = '#<wl:include\ (([a-zA-Z0-9]*)=(.*))*\/>$#iU';
junxiong
(Junxiong)
4
@Gustavo
Wow, what a quick reply 
I’ve tried but unfortunately it doesn’t work
@Jpenguin
Thanks… I’ll try it later…
currently not on my working laptop 
junxiong
(Junxiong)
5
unfortunately adding $ still doesn’t solve it…
junxiong
(Junxiong)
6
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