Reg Expression - Find/Replace Inside File
Reg Expression - Find/Replace Inside File
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.
Reg Expression - Find/Replace Inside File
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"
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"
Reg Expression - Find/Replace Inside File
Also I put this task into our repository
Reg Expression - Find/Replace Inside File
Oleg wrote: Also I put this task into our repository
Hi, Oleg.
Thanks so much! It works great!
All the best!