I have a use case that involves a step that requires a regex match. I need to match a text value and then get X words before it and X words after it. In searching thus far, Forum posts don’t address this specifically. My searches have been via the Edge browser which returns the Edge chat results along with Edge search results. The full response is attached. It reflects this as a solution. This example is for 3 words before and 3 words after a match.
(?<=\b\w+\b\s){3}(.*?)(?=\s\b\w+\b){3}
I am not able to get this to work in a standard ASSIGN activity like System.Text.RegularExpressions.Regex.Matches(…).
I would greatly appreciate the feedback of someone who can provide a UiPath syntax for getting X words before and X words after a match.
Thanks VERY much Pratik. You responded with a post that was also a solution but for some reason I can’t mark both as a solution. I very much appreciate your support on this issue.
One more question Yoichi if you don’t mind. This worked perfectly to populate the MATCH variable. m = System.Text.RegularExpressions.Regex.Match(strData,“(?(\S+\s+){1,3})target(?(\s+\S+){1,3})”)
The value ‘target’ above is a specific string value. To implement this match, I will pass a variable into that string where ‘target’ is. I am having trouble updating the ASSIGN activity to use a variable there. I get this error.