Have regex only return one item?
Posted: Sat Mar 21, 2020 4:47 pm
Hi there,
The Task at the bottom is meant to locate the time in a string of text, then save it to a variable for re-use. I don't want it to get all of the subexpressions though... I only want it to get "2:45pm." Ideas how to do this?
EDIT: Actually, it looks like checking the "No AutoCapture" box is the answer...
Second Edit: Or maybe not. (See Oleg's reply)
---------------------------
RoboTask: TimeGetter
---------------------------
Time = 2:45pm,2:45pm,2:4,pm,pm
---------------------------
OK
---------------------------
fyi This was made from copying Oleg's IP Address task :- }
The Task at the bottom is meant to locate the time in a string of text, then save it to a variable for re-use. I don't want it to get all of the subexpressions though... I only want it to get "2:45pm." Ideas how to do this?
EDIT: Actually, it looks like checking the "No AutoCapture" box is the answer...
Second Edit: Or maybe not. (See Oleg's reply)
---------------------------
RoboTask: TimeGetter
---------------------------
Time = 2:45pm,2:45pm,2:4,pm,pm
---------------------------
OK
---------------------------
fyi This was made from copying Oleg's IP Address task :- }
Code: Select all
;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|327331060
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
Events=FOLDER
ExternalName=STRING|"Task3"
Hide=INTEGER|0
ID=INTEGER|1840723945
LogOnAsUser=INTEGER|1
Name=STRING|"TimeGetter"
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 reTime Match"
Params=FOLDER
[Actions\Action1\Params]
anchored=STRING|"0"
case=STRING|"1"
extended=STRING|"0"
line00000000=STRING|"The time will be 2:45pm next Wednesday."
linecount=STRING|"1"
multiline=STRING|"0"
noautocapture=STRING|"0"
pattern=STRING|"\b(([0-2]?[0-9]:[0-5])[0-9](\s?(pm|am|p|a)?)|[12]?[0-9](pm|am|p|a))\b"
savesubexpression=STRING|"1"
singleline=STRING|"0"
subexpressionpos=STRING|"0"
subexpressionvar=STRING|"reTime"
ungreedy=STRING|"0"
useexternal=STRING|"0"
variable=STRING|"found"
[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|"{found}"
[Actions\Action3]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""Time = {reTime}"""
Params=FOLDER
[Actions\Action3\Params]
icon=STRING|"1"
msg0=STRING|"Time = {reTime}"
msgcount=STRING|"1"
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 ""Not found."""
Params=FOLDER
[Actions\Action5\Params]
icon=STRING|"0"
msg0=STRING|"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"
[Events]
Event1=FOLDER
[Events\Event1]
Enabled=INTEGER|-1
EventID=STRING|"E_GENERAL_HOTKEY"
Name=STRING|"Shift+Ctrl+Alt+C"
Params=FOLDER
UniqueID=INTEGER|1635334739
[Events\Event1\Params]
hotkey=STRING|"57411"