Reg Expression - Find/Replace Inside File

Discuss RoboTask here
Post Reply
MCHAL
Posts: 7
Joined: Sun Oct 07, 2007 8:26 am
Location: Brazil
Contact:

Reg Expression - Find/Replace Inside File

Post by MCHAL »

Hi,Could you anyone of you guys tell me how a Reg Expression should read for replacing a string such as  "English" with "Portuguese" inside an .xml file?Thanks in advance.Kind regards.
Oleg
Site Admin
Posts: 3201
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Reg Expression - Find/Replace Inside File

Post by Oleg »

See the example below
XML is a text file, because this example should help you.

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************

[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|1597096124
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task1079"
Hide=INTEGER|0
ID=INTEGER|462569279
LocalVariables=STRING|"newtext"
LogOnAsUser=INTEGER|1
Name=STRING|"Regexp demo - Replace English to Portuguese"
OnErrorTaskID=INTEGER|0
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER

[Actions\Action1]
ActionID=STRING|"A_REGEXP_REPLACE"
Enabled=INTEGER|-1
Name=STRING|"RegExp Replace"
Params=FOLDER

[Actions\Action1\Params]
anchored=STRING|"0"
case=STRING|"0"
extended=STRING|"0"
file=STRING|"C:\incoming\sample.txt"
linecount=STRING|"0"
multiline=STRING|"0"
noautocapture=STRING|"0"
pattern=STRING|"(?i)(english)"
replacementcount=STRING|"0"
repline00000000=STRING|"Portuguese"
replinecount=STRING|"1"
singleline=STRING|"0"
ungreedy=STRING|"0"
useexternal=STRING|"1"
variable=STRING|"newtext"

[Actions\Action2]
ActionID=STRING|"A_FILE_TEXTWRITE"
Enabled=INTEGER|-1
Name=STRING|"Create text file C:\incoming\sample1.txt"
Params=FOLDER

[Actions\Action2\Params]
fileexists=STRING|"0"
filname=STRING|"C:\incoming\sample1.txt"
line0=STRING|"{newtext}"
linecount=STRING|"1"
suppress=STRING|"0"
Oleg
Site Admin
Posts: 3201
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Reg Expression - Find/Replace Inside File

Post by Oleg »

Also I put this task into our repository
MCHAL
Posts: 7
Joined: Sun Oct 07, 2007 8:26 am
Location: Brazil
Contact:

Reg Expression - Find/Replace Inside File

Post by MCHAL »

Oleg wrote: Also I put this task into our repository


Hi, Oleg.

Thanks so much! It works great!

All the best!
Post Reply