jrblas has asked for the wisdom of the Perl Monks concerning the following question:
The regular expression...
/ABCD{3}.E/...matches: ABCDDDJE ABCDDDLE ABCDDD6E ABCDDD?E
How should I write it to match all strings with 2 D letters in the 4th, 5th and 6th position, irrespectively of where they are within this segment
That is, to match: ABC6DDJE ABCD6DJE ABCDD6JE ABCDD6LE ... and so on
Better than brute force approaches, I would appreciate a generic way of writing this regular expression, since I want to apply it to cases with multiple repetitions and with variable length. For instance, regexp like this:
/D.{3}[A-Z]{3,15}[0-9]{6,8}[^D]{2}/Thanks a lot in advance, JR
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: regexp with mismatches
by JavaFan (Canon) on Mar 25, 2012 at 16:33 UTC | |
|
Re: regexp with mismatches
by graff (Chancellor) on Mar 25, 2012 at 23:52 UTC | |
|
Re: regexp with mismatches
by Anonymous Monk on Mar 25, 2012 at 16:31 UTC |