Link to home
Start Free TrialLog in
Avatar of jay_waugh
jay_waughFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Find and replace Regex

I am looking to replace the value between two spaces in a string with a backslash. Can someone assist with the syntax.

E.G. I want

RED 123456789 White

to become

RED\White

Thanks
ASKER CERTIFIED SOLUTION
Avatar of aikimark
aikimark
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jay_waugh

ASKER

Thanks aikimark,

Sadly that doesn't seem to work for me. I am looking for a single line of regex. Apologies if any confusion has been caused by the Python reference on the this ticket, but the Experts Exchange window didn't seem to accept just "Regex"
What specifically isn't working for you?
I replaced the "regex" tag with "regular expressions"
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks both for your feedback.

My question is as simple as this. "Without using variables can I use a single regular expression to update a string so that the value held between two space characters is modified to be a backslash"

e.g.

RED 123456789 White = RED\White

or

Tree thebranchesof Bark = Tree\Bark
Avatar of Bill Prew
Bill Prew

Not sure what you mean by without using variables?  In the first reply to this question by aikimark there were no variables used.

You use the words "update a string" but the only way to update something is to have it in a variable.  You can start with one value and produce a new value from it, which is what aikimark showed.  Or you can start with a value in a variable and update that, which is what I showed.

If you are looking for something different not sure what you need.  Can you show the code you imagine?


»bp
OK thanks Bill, looks like I will have to go back to the drawing board a little and then be more specific