javascript - Regular expression to match content within curly braces without nested braces breaking it -


I currently use the {([^}] *)} content within a set of curly braces I'm matching , but this work stops when I close the other curly braces inside it.

I basically want to work with double crisp braces as any other lesson and it is nested except that grouped group, not a separate match or sub-match ( Not recursive) .

  {& lt; Div & gt; Works & lt; / Div & gt; } {& Lt; Div & gt; {{Failure}} & lt; / Div & gt; }  

Here I have a live example:

Any suggestions or advice will be appreciated.

I think you are looking for:

  {{{{{{{^ {^ {}} | {{^ ^}}}}) *)}  

Pattern description:

  { ((?: # Non-capturing group [^ {}] # # or {{[^}] *}} # There is no string within the double string bracket) # or more than zero times)}  

The idea of ​​using one more efficient way to do this:

  {({? {^ {}] | | {{[^}] *}} ) *)}  

Unfortunately, Javascript does not have this feature but you can make it a f Which can be used by the fact that the content of a lookhead is naturally atom:

  {((?: (? = ([^ {}} + | {{[^}] *}})) \ 2) *)}  

Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -