Wojtek Michalik said:
Can anybody give me en example of working regex
that will match sample text given below:
____________
banana\n
\tapple\n
____________
When including literal text in a post, quote it the way you would
quote it in Perl. Otherwise it is ambiguous. It appears that there are
two newlines between "banana" and "apple", because "\n" represents one
newline, and the actual newline (which causes them to be on separate lines)
represents another newline. Well, assuming the above is in double-quotish
circumstances, which reading further, I suspect it isn't.
Maybe it does, maybe it doesn't. Since it looks like you are using
the the i switch, I'm guessing that in fact \t represents '\t' and \n
represents '\n'.
I have been trying to match it by:
perl -pi -e 's#(banana\n\t)(apple)#$1\.\/$2#g' with modifiers like m s ms
Dealing with shell special characters and escaping, as well as perl special
characters and escaping, is a maddening proposition. If you can't make
your -e command-liner work, turn it into a real script before debugging.
Once you get your script to work, then you try turning it back into a
one-liner.
Also, simplify the substitution into a simple match. Once you get that
to work, you can go back to the substitution.
Finally, have you tried simply printing the input without modification so
you can see what it actually looks like?
Xho