Skip to content
Advertisement

Regex XML Selection Extract Element

I am trying make a regex selection starting from BYPASS 0 0 0 up to and including the section where it says WAK 0 0 Here is what I have (?s)(?=BYPASS).*?(WAK....) I think my syntax for python use is incorrect also here is how I use it in python script re.split(r'(?s)(?=BYPASS).*?(WAK....)', r) I believe this is causing the problem for me (?s) resulting with incorrect regex selections.

JavaScript

Advertisement

Answer

I am not sure what you mean by “regex selection”. The text you want can be matched with the regex (?s)(BYPASS 0 0 0.*?WAK 0 0) where:

JavaScript

You use re.split(regex, txt) that splits the string txt at the points specified by regex and returns an array of the new strings.

e.g.

JavaScript

If what you want is to get the parts that start from BYPASS 0 0 0 and end with WAK 0 0, you can use re.findall(regex, txt) that returns all the parts from txt that match regex.

e.g.

JavaScript

Or in your case

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement