Search code examples
javascriptregexregex-lookarounds

Alternatives to positive lookbehind REGEX when using JDE


I am using a JDE with embedded REGEX, that clearly doesn't support positive lookbehind (?<=text) nor (\Ktext). I'm looking to ignore a group without match or capture, as I don't have the ability to use group capture after the fact. This really needs to be performed at the initial REGEX level.

Sample is: 'Text statement says the same thing every time: 432' I'm trying to capture the number only.

(?<=Text statement says the same thing every time:)(.*?([0-9]+).*?)

The regex is simply placed into a text file that the JDE executes in order to create a named entity. As far as I know, I can only put regex statements into this text doc, and not call JS functions.

Any regex workaround?


Solution

  • Match but exclude from the result action is performed by lookbehinds or \K and by capturing groups.

    Capture the part you need with the expression, and set the result to Group 1.

    If this is not supported by your tool, log an enhancement request.

    If regex replacement is allowed, match the whole string and capture the part you need, replace with a backreference (\1 or $1), see proof.