I've been going mad trying to figure out how to do this--it should be
easy!
Allow the user to enter '\_sometext\_', i.e., literal backslash,
underscore, some text, literal backslash, underscore and, after
submitting via POST to a preg_replace filter, get back
'_sometext_' (i.e., the same thing with the literal backslashes
stripped)
Unless I'm misunderstandin g something (I don't know Perl at all), this
should work:
preg_replace( '/\\\\\\\\_(.*?)\ \\\\\\\_/i', '_$1_', $thepostvar )
but it doesn't, and I don't know why. The filter apparently leaves
the string unchanged, since it comes across in the POST array with the
backslash doubled, and it comes out of the filter with the backslash
still doubled. It doesn't seem to matter how many backslashes I use
in the filter--I've tried between 4 and 10--the result is the same.
Any insights?
thanks in advance,
Margaret
--
(To mail me, please change .not.invalid to .net, first.
Apologies for the inconvenience.)
easy!
Allow the user to enter '\_sometext\_', i.e., literal backslash,
underscore, some text, literal backslash, underscore and, after
submitting via POST to a preg_replace filter, get back
'_sometext_' (i.e., the same thing with the literal backslashes
stripped)
Unless I'm misunderstandin g something (I don't know Perl at all), this
should work:
preg_replace( '/\\\\\\\\_(.*?)\ \\\\\\\_/i', '_$1_', $thepostvar )
but it doesn't, and I don't know why. The filter apparently leaves
the string unchanged, since it comes across in the POST array with the
backslash doubled, and it comes out of the filter with the backslash
still doubled. It doesn't seem to matter how many backslashes I use
in the filter--I've tried between 4 and 10--the result is the same.
Any insights?
thanks in advance,
Margaret
--
(To mail me, please change .not.invalid to .net, first.
Apologies for the inconvenience.)
Comment