xinviseo
xinviseo

Reputation: 3

Matching a string between two sets of characters without using lookarounds

I've been working on some regex to try and match an entire string between two characters. I am trying to capture everything from "System", all the way down to "prod_rx." (I am looking to include both of these strings in my match). Below is the full text that I am working with:

\"alert_id\":\"123456\",\"severity\":\"medium\",\"summary\":\"System generated a Medium severity alert\\\\prod_rx.\",\"title\":\"123456-test_alert\",

The regex that I am using right now is...:

(?<=summary\\":\\").*?(?=\\")

This works perfectly when I am able to use lookarounds, such as in Regex101: https://regex101.com/r/jXltNZ/1. However, the regex parser in the software that my company uses does not support lookarounds (crazy, right?).

Anyway - my question is basically how can I match the above text described without using lookaheads/lookbehinds. Any help is VERY MUCH appreciated!!

Upvotes: 0

Views: 408

Answers (1)

Emma
Emma

Reputation: 27723

Well, we can simply use other non-lookaround method, such as this simple expression:

.+summary\\":\\"(.+)\\",

and our data is in this capturing group:

(.+)

our right boundary is:

\\",

and our left boundary is:

.+summary\\":\\"

Demo

Upvotes: 1

Related Questions