I have my own CMS and I use custom tags much more complicated than that - with properties and other rubbish. I can help you make this work.
Firstly, \s = all white space, including \r \n \t and so on. I can only assume whoever suggested you try that alternative doesn't have much experience with reg exp.
Secondly, you keep playing with your switches, but do you actually know what they mean? First you had, /mg, then you tried /i.
/i = ignore case
/g = global match (finds as many matches as possible)
/ig = ignore case & global match
I have never seen or heard of /m. I left the /m switch in my suggestion because I didn't know (and still don't know) what platform you're working on, but I guess /m may be the problem.
Problems I found in your regexp:
- \d will only matche DIGITS, not letters. it would match startcontent_
1234 but not startcontent_
hello.
- you had a / before the end }}, so you were actually searching for {{startcontent_1234
/}}
So here's my revised suggestion:
- [\s\S]*? - lazy match anything between tags (this will work)
- escape all literal symbols such as {, }, / and _ (to make sure)
- /ig switch (to make sure)
- use \w instead of \d
- Code: Select all
/\{\{startcontent\_/\w{2,50}\}\}([\s\S]*?)\{\{endcontent\_/\w{2,50}\}\}$/ig