Help with Regex

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
User avatar
kengrubb
Posts: 324
Joined: Thu Dec 11, 2003 5:23 pm
Location: Olympia, WA, USA

Help with Regex

Post 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.
(2[Bb]|[^2].|.[^Bb])

That is the question.
User avatar
AmigoJack
Posts: 596
Joined: Sun Oct 30, 2016 4:28 pm
Location: グリーン ヒル ゾーン
Contact:

Re: Help with Regex

Post 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).
User avatar
kengrubb
Posts: 324
Joined: Thu Dec 11, 2003 5:23 pm
Location: Olympia, WA, USA

Re: Help with Regex

Post 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.
(2[Bb]|[^2].|.[^Bb])

That is the question.
User avatar
kengrubb
Posts: 324
Joined: Thu Dec 11, 2003 5:23 pm
Location: Olympia, WA, USA

Re: Help with Regex

Post 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)
(2[Bb]|[^2].|.[^Bb])

That is the question.
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

The ordering isn't quite right. Try
^.{5}(?!.*get )(?:[^*].*)?\*isn
User avatar
kengrubb
Posts: 324
Joined: Thu Dec 11, 2003 5:23 pm
Location: Olympia, WA, USA

Post by kengrubb »

ben_josephs wrote:The ordering isn't quite right. Try
^.{5}(?!.*get )(?:[^*].*)?\*isn
A great many thanks!
(2[Bb]|[^2].|.[^Bb])

That is the question.
Post Reply