• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 227
  • Last Modified:

regular expression

I need a regular expression that searches for:

either one of approved, approving, approve, or one of terminated, terminate, termination, and they need to occur within 100 words of another instance...

such as: approved blah blah blah blah blah blah blah terminated blah blah
or: terminated blah blah blah blah blah terminate blah blah blah
0
GrnEggsAndHam
Asked:
GrnEggsAndHam
  • 3
  • 2
1 Solution
 
Bob LearnedCommented:
Start with the expression:

approv(ed|ing|e))|terminat(ed|e|ion)

Then look at each match, and get the Match.Index property (position within string) for each match and calculate the offset.

Bob
0
 
YurichCommented:
what about approves and terminates?? ;)
0
 
Bob LearnedCommented:
That wasn't in the list, but here you go:

approv(ed|ing|e|es))|terminat(ed|e|ion|es)

The '|' operator is the 'or' operator.  So this reads like this:

approved or approving or approve or approves or terminated or terminate or termination or terminates

Bob
0
 
YurichCommented:
I was just kidding, Roberto ;)
0
 
Bob LearnedCommented:
Hard to tell sometimes Mik *GRIN*

Bob
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now