Home > Back-end >  Consult a regular expression how to write?
Consult a regular expression how to write?

Time:05-20

Made a CMS, there are some logical custom if need nested tags, the regular expression is written such
 
\ {feather - CMS: if [\ t] +. * \} ([\ s \ s] +)? \ {/feather - CMS: if \}

The separate parsing the nested there is no problem, can find the end of the right tag
 
{feather - CMS: if test="(' 1 'eq 1)"}
Dfadsfadsf a
{/feather - CMS: if}

But with nested, such as this:
 
{feather - CMS: if test="(' 1 'eq (2)"}
{feather - CMS: if test="(' 1 'eq 1)"}
123
{/feather - CMS: if}
{/feather - CMS: if}

When ending tag had a problem, the regular how to improve it, thank you big!!

CodePudding user response:

\ {feather - CMS: if [\ t] +. * \}
([\ s \ s] +?
\ {/feather - CMS: if \}

You are the three parts, that can put the part of the circle plus +, respectively before and after on behalf of one or more times

CodePudding user response:

No, this is a question of nested

CodePudding user response:

More stupid method
(\ {feather - CMS: if [\ t] +. * \} | [^ \ {feather - CMS: if [\ t] +. * \} | \ {/feather - CMS: if \}] + | \ {/feather - CMS: if \})
Syntax validation, which means that each part match out alone, then write a recursive cycles
  • Related