Nested tags
Posted: Tue Jan 01, 2008 4:43 pm
Hi,
I have a regex hereto catch tags (my own tags, not html) like <hello>some other text</hello>, which works fine.
But I want to handle nested tags like <hello><world>some text</world></hello>, and I now need to find a way to
let it match tags that do NOT contain any other tags inside them, like the first example.
I presume I'll have to exclude it from the (.*?) group, but I don't know how to implement it.
I tried but it didn't work.
Any help is appreciated,
S.
I have a regex here
Code: Select all
"#<([a-z0-9-_]+?)>(.*?)</\\1>#is"But I want to handle nested tags like <hello><world>some text</world></hello>, and I now need to find a way to
let it match tags that do NOT contain any other tags inside them, like the first example.
I presume I'll have to exclude it from the (.*?) group, but I don't know how to implement it.
I tried
Code: Select all
"#<([a-z0-9-_]+?)>([^(<([a-z0-9-_]+?)>(.*?)</\\1>)]*?)</\\1>#is"Any help is appreciated,
S.