Page 1 of 2

RegExp NOT WORK

Posted: Sun Sep 16, 2018 6:46 pm
by WellWisher
if use RegExp "External text file", not work.
Work only "Specified Text"

Re: RegExp NOT WORK

Posted: Mon Sep 17, 2018 8:01 am
by Oleg
I just tested RegExp actions
They work with external file.

Could you send your example of the task and external file. It seems you do something wrong.

Re: RegExp NOT WORK

Posted: Mon Sep 17, 2018 12:23 pm
by WellWisher

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|0
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task3"
Hide=INTEGER|0
ID=INTEGER|877119748
LogOnAsUser=INTEGER|1
Name=STRING|"RegExp Replace..."
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

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

[Actions\Action1]
ActionID=STRING|"A_INET_DOWNLOAD"
Enabled=INTEGER|-1
Name=STRING|"Download files and save in ""{TEMPDIR}"""
Params=FOLDER

[Actions\Action1\Params]
action=STRING|"1"
authorization=STRING|"0"
file0=STRING|"https://ru.wikipedia.org/wiki/2018_%D0%B3%D0%BE%D0%B4_%D0%B2_%D0%BA%D0%BE%D0%BC%D0%BF%D1%8C%D1%8E%D1%82%D0%B5%D1%80%D0%BD%D1%8B%D1%85_%D0%B8%D0%B3%D1%80%D0%B0%D1%85"
filecount=STRING|"1"
password=STRING|"1473113755145321247900193"
proxykind=STRING|"0"
saveas=STRING|"1"
saveasname=STRING|"games.html"
savedir=STRING|"{TEMPDIR}"
useproxy=STRING|"0"

[Actions\Action2]
ActionID=STRING|"A_FILE_WAIT"
Enabled=INTEGER|-1
Name=STRING|"Wait accessibility of the file (games.html) infinetely"
Params=FOLDER

[Actions\Action2\Params]
filename=STRING|"{tempdir}\games.html"
mode=STRING|"0"
timeout=STRING|"0"

[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"
file=STRING|"{tempdir}\games.html"
linecount=STRING|"0"
multiline=STRING|"0"
noautocapture=STRING|"0"
pattern=STRING|"<b>.<.+b.*>"
replacementcount=STRING|"0"
replacemode=STRING|"0"
repline00000000=STRING|"robotask"
replinecount=STRING|"1"
singleline=STRING|"0"
ungreedy=STRING|"0"
useexternal=STRING|"1"
variable=STRING|"DATA"


Re: RegExp NOT WORK

Posted: Mon Sep 17, 2018 12:44 pm
by WellWisher
if same text, insert in "Specified Text", all work!

Re: RegExp NOT WORK

Posted: Mon Sep 17, 2018 1:14 pm
by Oleg
The problem that this HTML has utf-8 format. But the file has not utf-8 signature. So RoboTask reads the file AS-IT-IS as simple ASCII text file

You regexp action should find and replace these expressions in the file

Code: Select all

<b>Я<br />Н<br />В<br />А<br />Р<br />Ь</b>
<b>Ф</b><br /><b>Е</b><br /><b>В</b><br /><b>Р</b><br /><b>А</b><br /><b>Л</b><br /><b>Ь</b>
<b>М</b><br /><b>А</b><br /><b>Р</b><br /><b>Т</b>
<b>А<br />П<br />Р<br />Е<br />Л<br />Ь</b>
and so on - all 12 months.

But the file contains these expressions in UTF-8 format

Code: Select all

<b>РЇ<br />Рќ<br />Р’<br />Рђ<br />Р <br />Р¬</b>
<b>Р¤</b><br /><b>Р•</b><br /><b>Р’</b><br /><b>Р </b><br /><b>Рђ</b><br /><b>Р›</b><br /><b>Р¬</b>
<b>Рњ</b><br /><b>Рђ</b><br /><b>Р </b><br /><b>Рў</b>
<b>Рђ<br />Рџ<br />Р <br />Р•<br />Р›<br />Р¬</b>
You can see that these expressions doesn't match to your regular expression

So you need to read this file as UTF-8 file forcibly.
Look at the corrected task below

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|0
CatID=INTEGER|1597096124
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task508"
Hide=INTEGER|0
ID=INTEGER|877119748
LogOnAsUser=INTEGER|1
Name=STRING|"RegExp Replace... (Fixed)"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

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

[Actions\Action1]
ActionID=STRING|"A_INET_DOWNLOAD"
Enabled=INTEGER|-1
Name=STRING|"Download files and save in ""{TEMPDIR}"""
Params=FOLDER

[Actions\Action1\Params]
action=STRING|"1"
authorization=STRING|"0"
file0=STRING|"https://ru.wikipedia.org/wiki/2018_%D0%B3%D0%BE%D0%B4_%D0%B2_%D0%BA%D0%BE%D0%BC%D0%BF%D1%8C%D1%8E%D1%82%D0%B5%D1%80%D0%BD%D1%8B%D1%85_%D0%B8%D0%B3%D1%80%D0%B0%D1%85"
filecount=STRING|"1"
password=STRING|"1473113755145321247900193"
proxykind=STRING|"0"
saveas=STRING|"1"
saveasname=STRING|"games.html"
savedir=STRING|"{TEMPDIR}"
useproxy=STRING|"0"

[Actions\Action2]
ActionID=STRING|"A_FILE_WAIT"
Enabled=INTEGER|-1
Name=STRING|"Wait accessibility of the file (games.html) infinetely"
Params=FOLDER

[Actions\Action2\Params]
filename=STRING|"{tempdir}\games.html"
mode=STRING|"0"
timeout=STRING|"0"

[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"
file=STRING|"{tempdir}\games.html"
line00000000=STRING|"{TextFileUTF8({tempdir}\games.html)}"
linecount=STRING|"1"
multiline=STRING|"0"
noautocapture=STRING|"0"
pattern=STRING|"<b>.<.+b.*>"
replacementcount=STRING|"0"
replacemode=STRING|"0"
repline00000000=STRING|"robotask"
replinecount=STRING|"1"
singleline=STRING|"0"
ungreedy=STRING|"0"
useexternal=STRING|"0"
variable=STRING|"DATA"

[Actions\Action4]
ActionID=STRING|"A_FILE_TEXTWRITE"
Enabled=INTEGER|-1
Name=STRING|"Create text file {tempdir}\games1.html"
Params=FOLDER

[Actions\Action4\Params]
encode=STRING|"1"
fileexists=STRING|"0"
filname=STRING|"{tempdir}\games1.html"
line0=STRING|"{data}"
linecount=STRING|"1"
suppress=STRING|"0"

[Actions\Action5]
ActionID=STRING|"A_GENERAL_RUN_PROG"
Enabled=INTEGER|-1
Name=STRING|"Run ""games1.html """
Params=FOLDER

[Actions\Action5\Params]
ifnonzero=STRING|"0"
program=STRING|"{tempdir}\games1.html"
runas=STRING|"0"
wait=STRING|"0"


To make ASCII <==> UTF8 conversion you can use TXT UTF-8 Conversion action

Re: RegExp NOT WORK

Posted: Mon Sep 17, 2018 1:21 pm
by Oleg
if same text, insert in "Specified Text", all work!
Not same. The most text editors (including Notepad) makes automatic conversion of the text. But sometimes they are wrong.

Re: RegExp NOT WORK

Posted: Mon Sep 17, 2018 1:25 pm
by WellWisher
it's WORK! Thank you, very much Oleg!

Re: RegExp NOT WORK

Posted: Wed Sep 19, 2018 2:20 pm
by WellWisher
Not understand how work ReGex on Robotask. I use site https://regexr.com/ for check, but not match with RobotaskRegex
For Example:
Text

Code: Select all

==================================================
Name              : Discord
Type              : Application
Direction         : Render
Device Name       : Steam Streaming Speakers
Default           : 
Device State      : 
Muted             : No
Volume dB         : 
Volume Percent    : 86.5%
Min Volume dB     : 
Max Volume dB     : 
Volume Step       : 0.00 dB
Channels Count    : 1
Channels dB       : 
Channels  Percent : 100.0%
Item ID           : {0.0.1.00000000}.{c7c4e911-db79-4074-afa5-3d8196746aa5}|\Device\HarddiskVolume3\Users\DarDreams\AppData\Local\Discord\app-0.0.301\Discord.exe%b{00000000-0000-0000-0000-000000000000}|1%b10948
Command-Line Friendly ID: Steam Streaming Speakers\Application\Discord
Process Path      : C:\Users\DarDreams\AppData\Local\Discord\app-0.0.301\Discord.exe
Process ID        : 10948
Window Title      : 
==================================================
Name              : Google Chrome
Type              : Application
Direction         : Render
Device Name       : Steam Streaming Speakers
Default           : 
Device State      : 
Muted             : No
Volume dB         : 
Volume Percent    : 100.0%
Min Volume dB     : 
Max Volume dB     : 
Volume Step       : 0.00 dB
Channels Count    : 2
Channels dB       : 
Channels  Percent : 100.0%, 100.0%
Item ID           : {0.0.0.00000000}.{9c360359-2e3d-4a77-971a-5de310f0fa33}|\Device\HarddiskVolume3\Program Files (x86)\Google\Chrome\Application\chrome.exe%b{00000000-0000-0000-0000-000000000000}|1%b10516
Command-Line Friendly ID: Steam Streaming Speakers\Application\Google Chrome
Process Path      : C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
Process ID        : 10516
Window Title      : RegExr: Learn, Build, & Test RegEx - Google Chrome
==================================================
Pattern

Code: Select all

=((\n).+)(discord)((\n).*){1,}Volume\spercent.*(\s\d.*?%)((\n).*){1,}discord.exe
on site, all match, but not Robotask, why?

Re: RegExp NOT WORK

Posted: Wed Sep 19, 2018 9:06 pm
by Oleg
Use the expression

Code: Select all

(?im)=((\r\n).+)(discord)((\r\n).*){1,}Volume\spercent.*(\s\d.*?%)((\r\n).*){1,}discord\.exe
(?im) - modifier Case insensitive and Multiline text. You can use Advanced Options instead of this modifier
Use \r\n instead of \n. RoboTask uses multi-line text with \r\n line separator.

Also minor note: use discord\.exe instead of discord.exe at the end of the pattern

Also look at my example below. It works.

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|4870682
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task183"
Hide=INTEGER|0
ID=INTEGER|-17843387
LogOnAsUser=INTEGER|1
Name=STRING|"RegExp Match..."
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

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

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

[Actions\Action1\Params]
anchored=STRING|"0"
case=STRING|"0"
extended=STRING|"0"
line00000000=STRING|"=================================================="
line00000001=STRING|"Name              : Discord"
line00000002=STRING|"Type              : Application"
line00000003=STRING|"Direction         : Render"
line00000004=STRING|"Device Name       : Steam Streaming Speakers"
line00000005=STRING|"Default           : "
line00000006=STRING|"Device State      : "
line00000007=STRING|"Muted             : No"
line00000008=STRING|"Volume dB         : "
line00000009=STRING|"Volume Percent    : 86.5%"
line0000000A=STRING|"Min Volume dB     : "
line0000000B=STRING|"Max Volume dB     : "
line0000000C=STRING|"Volume Step       : 0.00 dB"
line0000000D=STRING|"Channels Count    : 1"
line0000000E=STRING|"Channels dB       : "
line0000000F=STRING|"Channels  Percent : 100.0%"
line00000010=STRING|"Item ID           : {0.0.1.00000000}.{c7c4e911-db79-4074-afa5-3d8196746aa5}|\Device\HarddiskVolume3\Users\DarDreams\AppData\Local\Discord\app-0.0.301\Discord.exe%b{00000000-0000-0000-0000-000000000000}|1%b10948"
line00000011=STRING|"Command-Line Friendly ID: Steam Streaming Speakers\Application\Discord"
line00000012=STRING|"Process Path      : C:\Users\DarDreams\AppData\Local\Discord\app-0.0.301\Discord.exe"
line00000013=STRING|"Process ID        : 10948"
line00000014=STRING|"Window Title      : "
line00000015=STRING|"=================================================="
line00000016=STRING|"Name              : Google Chrome"
line00000017=STRING|"Type              : Application"
line00000018=STRING|"Direction         : Render"
line00000019=STRING|"Device Name       : Steam Streaming Speakers"
line0000001A=STRING|"Default           : "
line0000001B=STRING|"Device State      : "
line0000001C=STRING|"Muted             : No"
line0000001D=STRING|"Volume dB         : "
line0000001E=STRING|"Volume Percent    : 100.0%"
line0000001F=STRING|"Min Volume dB     : "
line00000020=STRING|"Max Volume dB     : "
line00000021=STRING|"Volume Step       : 0.00 dB"
line00000022=STRING|"Channels Count    : 2"
line00000023=STRING|"Channels dB       : "
line00000024=STRING|"Channels  Percent : 100.0%, 100.0%"
line00000025=STRING|"Item ID           : {0.0.0.00000000}.{9c360359-2e3d-4a77-971a-5de310f0fa33}|\Device\HarddiskVolume3\Program Files (x86)\Google\Chrome\Application\chrome.exe%b{00000000-0000-0000-0000-000000000000}|1%b10516"
line00000026=STRING|"Command-Line Friendly ID: Steam Streaming Speakers\Application\Google Chrome"
line00000027=STRING|"Process Path      : C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
line00000028=STRING|"Process ID        : 10516"
line00000029=STRING|"Window Title      : RegExr: Learn, Build, & Test RegEx - Google Chrome"
line0000002A=STRING|"=================================================="
linecount=STRING|"43"
multiline=STRING|"0"
noautocapture=STRING|"0"
pattern=STRING|"(?im)=((\r\n).+)(discord)((\r\n).*){1,}Volume\spercent.*(\s\d.*?%)((\r\n).*){1,}discord\.exe"
savesubexpression=STRING|"1"
singleline=STRING|"0"
subexpressionpos=STRING|"0"
subexpressionvar=STRING|"expr"
ungreedy=STRING|"0"
useexternal=STRING|"0"
variable=STRING|"res"

[Actions\Action2]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If Then"
Params=FOLDER

[Actions\Action2\Params]
case=STRING|"0"
connection=STRING|"0"
count=STRING|"1"
operator=STRING|"0"
type=STRING|"3"
value1=STRING|"{res}"

[Actions\Action3]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""Expression is found"""
Params=FOLDER

[Actions\Action3\Params]
icon=STRING|"1"
msg0=STRING|"Expression is found"
msg2=STRING|"{expr(0)}"
msgcount=STRING|"3"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action4]
ActionID=STRING|"A_FLOW_ELSE"
Enabled=INTEGER|-1
Name=STRING|"Else"

[Actions\Action5]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""Expression is NOT found"""
Params=FOLDER

[Actions\Action5\Params]
icon=STRING|"3"
msg0=STRING|"Expression is NOT found"
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action6]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"
Save the text of the task to a file and use menu Task->Import to import the task into RoboTask.

Re: RegExp NOT WORK

Posted: Thu Sep 20, 2018 12:19 am
by WellWisher
Thank you Oleg, problem was with "\r \n", i just begin learn RegEx, and you very help me.