Page 1 of 1

Multiple RegEx

Posted: Thu Aug 07, 2014 4:24 pm
by Ulist
At the moment I'm trying to implement some extensive conversion workflows with RoboTask. Basically everthing works fine but I have to do some RegEx operations with a lot of searches and replacements (> 50 per task). As RoboTask provides only one RegEx per step I'm wondering if there is an easy way to get this done. One option would be, to use "Search and Replace" from funduc that allows for long lists with S&R operations. Another option would be to use a Perl scipt but is there an option inside of RoboTask that helps to keep the software zoo small?

Thanks in advance for any suggestion
Ulist

Re: Multiple RegEx

Posted: Thu Aug 07, 2014 4:43 pm
by Oleg
Why do you not want to make 50 or more steps for Search&Replace?
If you have several criteria for S&R operation you have to make several steps 1 step for each operation.

Anyway algorithm depends on your goal. Somtimes possible to simplify the algorithm (e.g. to process operation in the loop)

Re: Multiple RegEx

Posted: Thu Aug 07, 2014 5:35 pm
by Ulist
If you have to make stupid replacements like these
/o\.\s*B\./o.€B./g
/o\.\s*G\./o.€G./g
...
it's easier to control what is done if all replacements are in one text file.

If I would use 50 RexEx steps the first step would read an external text file an write the result to a variable. All following steps would use this variable as "Specified Text" instead of reading an external file again. Is this right?

Re: Multiple RegEx

Posted: Thu Aug 07, 2014 8:35 pm
by Oleg
Yes of course
You can read the file only in the 1-st step.
Next steps may process the text in variable and save the result into the same variable.
You can save the final text into a file only in the last step.

See small example below:

Code: Select all

 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|1416408852
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task118"
Hide=INTEGER|0
ID=INTEGER|1164447761
LogOnAsUser=INTEGER|1
Name=STRING|"sample regex"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""MYVAR"" with value """""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"MYVAR"

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

[Actions\Action2\Params]
anchored=STRING|"0"
case=STRING|"0"
extended=STRING|"0"
file=STRING|"c:\temp\MyFile.txt"
linecount=STRING|"0"
multiline=STRING|"0"
noautocapture=STRING|"0"
pattern=STRING|"o\.\s*B\."
replacementcount=STRING|"0"
repline00000000=STRING|"o.€B."
replinecount=STRING|"1"
singleline=STRING|"0"
ungreedy=STRING|"0"
useexternal=STRING|"1"
variable=STRING|"MyVar"

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

[Actions\Action3\Params]
anchored=STRING|"0"
case=STRING|"0"
extended=STRING|"0"
line00000000=STRING|"{MyVar}"
linecount=STRING|"1"
multiline=STRING|"0"
noautocapture=STRING|"0"
pattern=STRING|"o\.\s*G\."
replacementcount=STRING|"0"
repline00000000=STRING|"o.€G."
replinecount=STRING|"1"
singleline=STRING|"0"
ungreedy=STRING|"0"
useexternal=STRING|"0"
variable=STRING|"MyVar"

[Actions\Action4]
ActionID=STRING|"A_MISC_COMMENT"
Enabled=INTEGER|-1
Name=STRING|"//and etc. Make all necessary replacements"
Params=FOLDER

[Actions\Action4\Params]
comment=STRING|"and etc. Make all necessary replacements"

[Actions\Action5]
ActionID=STRING|"A_FILE_TEXTWRITE"
Enabled=INTEGER|-1
Name=STRING|"Create text file c:\temp\MyFile-1.txt"
Params=FOLDER

[Actions\Action5\Params]
encode=STRING|"0"
fileexists=STRING|"0"
filname=STRING|"c:\temp\MyFile-1.txt"
line0=STRING|"{MyVar}"
linecount=STRING|"1"
suppress=STRING|"0"
BTW: you can duplicate steps by using copy/paste (Ctrl-C, Ctrl-V). Next you can only change step parameters.