in reply to Re: Regular Expressions: Removing 'only' single spaces from a string
in thread Regular Expressions: Removing 'only' single spaces from a string

what does the $1$2 mean? Doesn't the $ regular expression designate the end of the string?
  • Comment on Re^2: Regular Expressions: Removing 'only' single spaces from a string

Replies are listed 'Best First'.
Re^3: Regular Expressions: Removing 'only' single spaces from a string
by GrandFather (Saint) on Oct 20, 2005 at 23:31 UTC

    In the regular expression, yes it does. In the replacement expression $n is the n'th capture string in the regular expression. So for s/(x) (y)/$1$2)/ 'x y' gets replaced with 'xy' for example.


    Perl is Huffman encoded by design.