Trying to puzzle this one out, and it's enough fun that I wanted to share it with my fellow monks (as well as hoping that someone has an answer. :) A regex _should_ be able to do this, but I'm kinda stuck on how.
So, is there a way to have the '\n' be part of the character class that's being captured? Or did I just run up against an actual limitation, and absolutely have to do it "in two parts", like one of the last two lines?#!/usr/bin/perl -w use strict; # Need to 'unescape' the escaped characters $_ = 'Goodbye\; Good luck\, and thanks for all the fish!\\n\\n'; # s/\\([;,\n])/$+/g; # Doesn't match '\\n' # s/\\([;,n])/$1/g; # Matches '\\n', but turns it into 'n' # s#\\n|\\([;,])#$1||$/#ge; # Works, but... UGH. # s/\\n/\n/g; s/\\(;|,)/$1/g; # Yah, yah, shure. print;
-- Education is not the filling of a pail, but the lighting of a fire. -- W. B. Yeats
In reply to Regexes and backslashes by oko1
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |