sakej Posted September 5, 2018 Posted September 5, 2018 (edited) Hi. Im trying to replace \ with / with this code Local $stringReplace="//something/something" Local $stringReplace2=StringRegExpReplace($stringReplace, '/', '\') but this dosent work, all i get is a string that looks like that "somethingsomething". Anyone? Edited September 5, 2018 by sakej
FrancescoDiMuro Posted September 5, 2018 Posted September 5, 2018 Hi @sakej Is this what you were looking for? Global $strString = "//something/moresomething/moremoresomething/" ConsoleWrite("String before: '" & $strString & "'" & @CRLF & _ "String after: '" & StringReplace($strString, "/", "\") & "'" & @CRLF) Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
rudi Posted September 5, 2018 Posted September 5, 2018 Hi. you need to "escape" the "\" in your (one char) replace string: Local $stringReplace="//something/something" Local $stringReplace2=StringRegExpReplace($stringReplace, '/', '\\') ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $stringReplace2 = ' & $stringReplace2 & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console regards, rudi. sakej 1 Earth is flat, pigs can fly, and Nuclear Power is SAFE!
sakej Posted September 5, 2018 Author Posted September 5, 2018 Thanks @rudi I've been banging my head over this for an hour now. It works now with escaping
ViciousXUSMC Posted September 5, 2018 Posted September 5, 2018 Yes if you use regex you need to escape it. If you just use stringreplace() you do not, and for this particular task the normal string replace is adequate as your not really demanding anything that needs regex. mikell 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now