(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?
Eventually I want to convert a string like " This is some text \0\0\0" to " This is some text".
Greets,
Coen
__________________________________________________________ Deze e-mail en de inhoud is vertrouwelijk en uitsluitend bestemd voor de geadresseerde(n). Indien u niet de geadresseerde bent van deze e-mail verzoeken wij u dit direct door te geven aan de verzender door middel van een reply e-mail en de ontvangen e-mail uit uw systemen te verwijderen. Als u geen geadresseerde bent, is het niet toegestaan om kennis te nemen van de inhoud, deze te kopieren, te verspreiden, bekend te maken aan derden noch anderszins te gebruiken.
The information contained in this e-mail is confidential and may be legally privileged. It is intended solely for the addressee. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. Please notify us immediately if you have received it in error by reply e-mail and then delete this message from your system. __________________________________________________________
Regex re = Regex("[a]$"); string result = re->replace(test,"");
My result is:
object reg = Regexp.PCRE.Studied("[a]$"); string result = re->replace(test,""); result;
(2) Result: "aaa123aa"
results in: "123b" while I want it to be 'aaa123'.
using "^[a]" results in "123aaa".
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.
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.
Good question. The PCRE code should be easy to read though, feel free to investigate? :)
Sounds like something that should be added to the testsuite, anyway. Both of the problems...
pike-devel@lists.lysator.liu.se