Hello,
(using pike 7.4 r464)
I want to replace something at the end of a string, but I can't get it done: I don't know the exact contents of the string when executing code, mind you.
string test = "aaa123aaa";
Regex re = Regex("[a]$"); string result = re->replace(test,"");
results in: "123b" while I want it to be 'aaa123'.
using "^[a]" results in "123aaa".
What am I doing wrong?
I can't manage to use $ with SimpleRegexp too (Pike 7.6), while ^ works.
Eventually I want to convert a string like " This is some text \0\0\0" to " This is some text".
Using Pike 7.6 (7.6.112) and PCRE, this seems to work:
----8<----8<----8<----8<---- $ pike Pike v7.6 release 112 running Hilfe v3.5 (Incremental Pike Frontend)
string foo = " This is some text \0\0\0"; object r = Regexp.PCRE.Studied("[\W]+$"); r->replace(foo, "");
(1) Result: " This is some text" ---->8---->8---->8---->8----
However, i'd like to know why while doing this: ----8<----8<----8<----8<----
object r = Regexp.PCRE.Studied("[\W]*$"); r->replace(foo, "");
---->8---->8---->8---->8---- Pike eats all my CPU and the command never finish.