Jump to content

Multi escape special characters - (Moved)


Recommended Posts

Hi,

I'm searching for a solution to multi-escape the AutoIT special characters, like !, ^, { and }. I've created a Loop through the given string using the help from most of the members here, but it keeps bugging me with re-escaping already escaped characters, like { and }.

Here's what I have up until now:

$sPassword = "W@l}c0me{123)}ab!+25^}"

$sGoodpassword = $sPassword
ConsoleWrite($sGoodpassword & @CRLF)

Local $a_rep[6][2] = [["{", "{{}"], ["}", "{}}"], ["!", "{!}"], ["#", "{#}"], ["+", "{+}"], ["^", "{^}"]]
For $i = 0 To Ubound($a_rep, 1) - 1
    $sGoodpassword = StringRegExpReplace($sGoodpassword, "\Q" & $a_rep[$i][0] & "\E", $a_rep[$i][1])
    ConsoleWrite($sGoodpassword & @CRLF)
Next

It starts with this output (the original string of course):
W@l}c0me{123)}ab!+25^}

It ends with this:
W@l{}}c0me{{{}}123){}}ab{!}{+}25{^}{}}

As you can see, the first few curly braces are re-escaped....

All the help will be appreciated.
Thanks!

Link to comment
Share on other sites

  • Developers

Moved to the appropriate forum, as the Developer General Discussion forum very clearly states:

Quote

General development and scripting discussions. If it's super geeky and you don't know where to put it - it's probably here.


Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums.

Moderation Team

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...