in reply to Regex letter order matching

Like this

m{ $before # whatever cb $after # whatever }msx;
where $before and $after are whatever prefix/suffix you need

Or did you want something else?

Replies are listed 'Best First'.
Re^2: Regex letter order matching
by Anonymous Monk on Mar 25, 2014 at 22:28 UTC

    that can work if you do TWO match operations

    1) match pattern to reject (the one with cb) 2) match pattern to accept (same exact pattern except no "cb" literal

    Or look ahead

    $ perl -Mre=debug -le " $_ = q{this TON that}; m{this \s+ (?!NOT)\w+ \ +s+that}msgx; " Compiling REx "this \s+ (?!NOT)\w+ \s+that" Final program: 1: EXACT <this> (3) 3: PLUS (5) 4: SPACE (0) 5: UNLESSM[0] (11) 7: EXACT <NOT> (9) 9: SUCCEED (0) 10: TAIL (11) 11: PLUS (13) 12: ALNUM (0) 13: PLUS (15) 14: SPACE (0) 15: EXACT <that> (17) 17: END (0) anchored "this" at 0 floating "that" at 7..2147483647 (checking floati +ng) minlen 11 Guessing start of match in sv for REx "this \s+ (?!NOT)\w+ \s+that" ag +ainst "this TON that" Found floating substr "that" at offset 9... Found anchored substr "this" at offset 0... Guessed: match at offset 0 Matching REx "this \s+ (?!NOT)\w+ \s+that" against "this TON that" 0 <> <this TON t> | 1:EXACT <this>(3) 4 <this> < TON that> | 3:PLUS(5) SPACE can match 1 times out of 21474 +83647... 5 <this > <TON that> | 5: UNLESSM[0](11) 5 <this > <TON that> | 7: EXACT <NOT>(9) failed... 5 <this > <TON that> | 11: PLUS(13) ALNUM can match 3 times out of 214 +7483647... 8 <his TON> < that> | 13: PLUS(15) SPACE can match 1 times out of 2 +147483647... 9 <his TON > <that> | 15: EXACT <that>(17) 13 <his TON that> <> | 17: END(0) Match successful! Freeing REx: "this \s+ (?!NOT)\w+ \s+that"