04-14-2010 04:51 PM
Hi,
I'm looking for nice and elegant solution to my problem. Let's say I have a string "e+exp(e)". I want to replace all "e" with "1", excepts the one in "exp". I was trying to use regular expressions but I've failed after an hour... The solution should be able to solve things like replace "a" in "rand(a)" without changing rand. Basically I need to replace single character without replacing the ones in words/expressions.
Any ideas?
Solved! Go to Solution.
04-14-2010 06:04 PM - edited 04-14-2010 06:06 PM
No time for elegance right now, just brute force. I would pad the string with spaces on each end to remove end cases and then search for the character surrounded by non-word characters.
04-15-2010 02:24 AM
04-15-2010 09:23 AM
04-15-2010 03:30 PM