Jump to content

StringRegExpReplace and HEX


Recommended Posts

You didn't supply a complete demo script, including how you defined $rtext before trying StringRegExpReplace(). Also note in your post what you wanted the output to be.

:blink:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Check the 2nd character in the replace, according to what I can find, 07T2 is not valid.

This works when I substitute 07172 for your 07T2

$rText = StringRegExpReplace($rText, "\x{07173", "$1) & ChrW(0x07172)

Now the question arises, Why are you using an SRE replace for a single character when a simple StringReplace would do it?

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Check the 2nd character in the replace, according to what I can find, 07T2 is not valid.

This works when I substitute 07172 for your 07T2

$rText = StringRegExpReplace($rText, "\x{07173", "$1) & ChrW(0x07172)

Now the question arises, Why are you using an SRE replace for a single character when a simple StringReplace would do it?

You're right about using StringReplace instead. The above 1 is actually an I. I'm converting some things over which I would normally do with Python and regular expressions (re.compile and re.sub) which work a little differently. I see now where the notation is slightly different. I'm just looking for the HEX 07 which I know there are various ways to do, but I'm trying to be consistent with other programs I use without converting from one numbering system to the next everytime I do something.

Edited by Madness
Link to comment
Share on other sites

Hex 07 can be expressed as \x07 in the SRE but hex numbers are limited to 2 characters so to use anything higher you need to use the {} method.

Also your "i" is not valid Hex, only 0-9 and (?i) a-f or you could take a look at using the :xdigit: class.

Also you should be aware that The PCRE engine as used in AutoIt does not properly support Unicode characters, if it did there would be a whole different solution for this.

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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...