in reply to regexp: ?<=
Some common usages of (?<=...), (?=...) and (?!...):
s/(?<=a)b/c/; # Changes the 'a', but keeps the 'b'. s/b(?=a)/c/; # Changes the 'a', but keeps the 'b'. /^(?=.*a)(?=.*b)/; # Is equivalent to /a/ && /b/. /a(?:(?!bcd).)*e/; # (?:(?!...).)* is to regexp what # [^...] is to characters. # This example reads as: # "Match 'a' followed by somethng which # doesn't contain 'bcd', followed by 'e'."
$& refers to "everything that was matched". It's what gets substituted in a substitution. Avoid actually using $&. It has side effects which can slow down other regexps in your program. It can easily be emulated using captures.
|
|---|