Posted 11 years ago by Jon Heaton
Version: 12.1.0302

How can I do if then else in RegexPatternGroups?  I've tried (?if then|else).  Any ideas?

I am modifying the html states and have some custom script that could be inside of an html attribute's value.  So if I encounter the string "[%" then I want to check for the ending string "%]" and allow quotes inside of the string, otherwise I want to match on anything but quotes ([^"]+).

Any help/suggestions appreciated.

Comments (2)

Posted 11 years ago by Jon Heaton

Also, do you support non-capturing groups?

Answer - Posted 11 years ago by Actipro Software Support - Cleveland, OH, USA

Hi Jon,

I'm sorry but our regex engine doesn't support alternations or non-capturing groups.

What you'd have to do is in the state for the attribute value, have a child state for your [% ... %] range.  Then have a pattern that consumes all characters except for quotes and [ characters.  That way, if a [ is in the value, the lexer will break and re-examine it to see if it is the start of a child state.

Actipro Software Support

The latest build of this product (v23.1.2) was released 13 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.