in reply to Re: Regex Semantics
in thread Regex Semantics
So, a regex that actually matched "A line beginning and ending with zero or more letters in the set/class {a}" would be
I didn't touch that in my post because both /^.*\z/s and 1 would be sufficient to match "A line beginning and ending with zero or more letters in the set/class {a}".
If you wanted a regexp that matched "A line beginning and ending with one or more letters in the set/class {a}", you'd use
/^[a]/ && /[a]\z/ (Two regexps),
/^(?=[a])(?=.*[a]\z)/s (Lookaheads) or
/^[a].*(?<=[a])\z)/s (One of the few times (?<=...) works.)
/^[a].*[a]\z/s would not do, since it wouldn't match "a".
|
|---|