Page 1 of 1

Help with Regex

Posted: Tue Apr 17, 2018 11:34 pm
by kengrubb
I've been puzzling over how to make this happen, and I just know there's someone way smarter than me with Regex who can make this happen.

I want to do a Regex Search to find this:
  • ^.{5}([^*].*\*isn|\*isn)
But not find this:
  • ^.{5}([^*].*get +.*\*isn|get +.*\*isn)
If someone is wondering, I'm working in Natural, as in Software AG Natural.

Re: Help with Regex

Posted: Wed Apr 18, 2018 7:18 am
by AmigoJack
kengrubb wrote:^.{5}([^*].*\*isn|\*isn)
This is redundant and equal to ^.{5}((?:[^*].*)?\*isn)
kengrubb wrote:But not find this
Use a negative lookahead: ^.{5}((?:[^*](?!.*get +).*)?\*isn)
kengrubb wrote:I'm working in Natural, as in Software AG Natural.
Not sure why you say that, but I thought this board always relates to TextPad (and its regular expression abilities).

Re: Help with Regex

Posted: Mon Apr 23, 2018 6:48 pm
by kengrubb
AmigoJack wrote:
kengrubb wrote:I'm working in Natural, as in Software AG Natural.
Not sure why you say that, but I thought this board always relates to TextPad (and its regular expression abilities).
I should have been clearer. I'm using Textpad to search and view Natural code.

Re: Help with Regex

Posted: Mon Apr 23, 2018 7:29 pm
by kengrubb
AmigoJack wrote:Use a negative lookahead: ^.{5}((?:[^*](?!.*get +).*)?\*isn)
I was thinking it should be negative lookbehind, but I haven't used them enough to really master them.

Getting hits on these strings using your RE.

Code: Select all

2580 GET RFRL-V *ISN(LABEL_3.)
1210 GET UPD-CLAIM *ISN (RD-CLM.)
1600 GET CLAIM *ISN (0980)

Posted: Mon Apr 23, 2018 8:17 pm
by ben_josephs
The ordering isn't quite right. Try
^.{5}(?!.*get )(?:[^*].*)?\*isn

Posted: Mon Apr 23, 2018 9:31 pm
by kengrubb
ben_josephs wrote:The ordering isn't quite right. Try
^.{5}(?!.*get )(?:[^*].*)?\*isn
A great many thanks!