RegexReplace intermittently fails in my script.

Get help with using AutoHotkey and its commands and hotkeys
devolve
Posts: 6
Joined: 17 Sep 2014, 09:49

RegexReplace intermittently fails in my script.

09 Oct 2014, 15:17

I have a very Rube Goldberg-style process in place to automate a tedious task at work. Part of this task involves parsing a text file that is generated by an ancient program. Everything is fine, except that this ancient program insists on inserting a Form Feed character (ASCII code 12) every so many lines of the file, and this causes problems.

As a workaround, I have this bit of AHK code to eliminate the FF character:

Code: Select all

FileRead, text_list, %MyFile%
text_list := RegExReplace(text_list, "♀", "", "", -1)
FileDelete, %MyFile%
FileAppend, %text_list%, %OutputFile% 
Most of the time, this works. But not all the time. I don't understand why it doesn't always work. I presume it's because I've done it all wrong, and that there is a better method.

Any ideas?
User avatar
RobertL
Posts: 540
Joined: 18 Jan 2014, 01:14
Location: China

Re: devolve

10 Oct 2014, 03:36

What's the error/issue when not work?
Maybe consider the encoding of file?
我为人人,人人为己?
devolve
Posts: 6
Joined: 17 Sep 2014, 09:49

Re: devolve

10 Oct 2014, 09:04

RobertL wrote:What's the error/issue when not work?
Maybe consider the encoding of file?
There is no error at all, it simply doesn't replace the character, and happily breezes along as if it did.
ahcahc
Posts: 110
Joined: 25 Jul 2014, 23:55

Re: RegexReplace intermittently fails in my script.

10 Oct 2014, 21:46

try text_list := RegExReplace(text_list, chr(12))
Coco
Posts: 771
Joined: 29 Sep 2013, 20:37
GitHub: cocobelgica

Re: RegexReplace intermittently fails in my script.

12 Oct 2014, 02:03

Works for me, what version of AutoHotkey are you using? Can you provide us with a rough idea on the contents of the file?
User avatar
AlphaBravo
Posts: 476
Joined: 29 Sep 2013, 22:59

Re: RegexReplace intermittently fails in my script.

12 Oct 2014, 10:44

just a thought MsgBox % Chr(12) " is not " Chr(9792)

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], dentopolis, Google [Bot], RubbeH, Xtra and 69 guests