On 07/26/2010 09:13 PM, Steven Watanabe wrote:
AMDG
codemonkey wrote:
... If I could express a literal newline
(e.g. n) in a regex then I could do it with something like this:
"^(.*)[n]$" but I can't find a way to do that (so far).
Use \n.
hmm... my original post had the "\" in there; not sure why it's missing
in your quote.
In any case, I did try \n but it didn't seem to work. Here's a rule
I wrote (based on the aforementioned strip-eol from mpi.jam):
rule rtrim ( string )
{
local match = [ MATCH "^(.*)[\n]$" : $(string) ] ;
if $(match)
{
return $(match[1]) ;
}
else
{
return $(string) ;
}
}
Note that I've tried it with and without the [] .
I looked at regexp.c and I can't see where it handles \n -- I'm not
sure it actually does. Unless I missed something, I think it treats
'\n' as just 'n'.
~ray