You are probably looking for /g, substitute globally. Your example will only get the first \r and \n in $blah. Just use something like this which will also handle DOS style returns
$blah =~ s/\r?\n/<br>/g;
| [reply] [d/l] |
Or, if you want to be really portable, you could use s/\r?\n|\n?\r//g. That should catch most every platform's newline style, IIRC.
bbfu
Black flowers blossom
Fearless on my breath
| [reply] [d/l] |
If the web client (browser) doesn't use ASCII "\r\n"1 for newline in the text it sends to you, then the web client is broken, IMHO.
1Note that this is not ambiguous. I know that "\r\n" on old Macs results in ASCII "\n\r", but that is because those Macs are near-ASCII systems despite them claiming to be ASCII systems. q-:
- tye
| [reply] |
If you don't mind having multiple consecutive line breaks (i.e. empty lines) collapsed into a single <br> tag, you could do:
$blah =~ s/[\r\n]+/<br>/g;
(Just because I don't recall off-hand... I'd like to test whether there's visible difference...
between single and double <br> tags... Yup, there is.) | [reply] [d/l] |
This doesn't have to deal with \n.... but is there an easy way to find any punctuation in a sentence and rip it out? or would I have to type in ?|.|,| and whatnot in the regex? | [reply] |
unless ($msg =~ /[a-z]|[A-Z]|[0-9]/g) {
$msg = "a";
}
and that seemed to fix the problem... so false alarm I guess | [reply] [d/l] |