in reply to Re: Re: Re: nested pattern matching
in thread nested pattern matching
What I'm getting at is that:
/[XYZ]{3}([A-Za-z]{0,21}?[ABC]{3}/g
will match both of the following strings:
"ASDFXYZOtherCharsABCASDF" "ASDFXXXOtherCharsAAAASDF"
If he intended to specifically match XYZ, and not XXX, then he needed the following regexp instead:
/XYZ([A-Za-z]{0,21}?ABC/g
Again, the OP's original regexp confirms that he wanted to match three characters from a class, zero to 21 characters from a class, and then three characters from another class.
But his choice of example strings showed him looking to match three specific characters, followed by zero to 21 characters from a class, followed by three more specific characters.
I just wanted to point out that there is a difference, just in case it turns out to be significant in the implementation planned by the original poster.
Dave
"If I had my life to do over again, I'd be a plumber." -- Albert Einstein
|
|---|