What kind of Regex does tasker use?

1,710 views
Skip to first unread message

Cliff Karlsson

unread,
Jan 15, 2014, 1:48:09 PM1/15/14
to tas...@googlegroups.com
I am a bit confused why some of my regex examples does not work in tasker but work when regexbuddy.

I have tried this:

data= <div id="clock-days">016<span class="timedesc">days&nbsp;</span></div>
Regex= (?<=<div id="clock-.*)\d.+(?=<span class="timedesc">)

I want to get the number 016

Message has been deleted

Bob Hansen

unread,
Jan 15, 2014, 1:58:34 PM1/15/14
to tas...@googlegroups.com

Tasker uses javascript "flavor" of regex.
Try:
(?<=<div id="clock-.+)\d+(?=<span class="timedesc">)

Bob Hansen

unread,
Jan 15, 2014, 2:03:34 PM1/15/14
to tas...@googlegroups.com
Actually that change wouldn't make a difference. Make sure you are using Save Matches To: %match (for example) and checking for the result in %match(1) (Tasker puts the matches in an array).

Cliff Karlsson

unread,
Jan 15, 2014, 2:48:33 PM1/15/14
to tas...@googlegroups.com
Are you sure that the regex is correct? When I switch to javascript in regexbuddy I can't match either.

Cliff Karlsson

unread,
Jan 15, 2014, 2:58:52 PM1/15/14
to tas...@googlegroups.com
Ok, I gave up on that one. Found something simpler that worked instead. >\d{2,3}<

Bob Hansen

unread,
Jan 15, 2014, 3:33:13 PM1/15/14
to tas...@googlegroups.com
Even simpler \d+

Tasker didn't like the clock-.*
I think it failed because it made the capture group variable length, but that is speculation. 

(?<=<div id="clock-.*)\d.+(?=<span class="timedesc">) 

this below works.

(?<=<div id="clock-days">)\d+(?=<span class="timedesc">) 

Matt R

unread,
Jan 15, 2014, 4:19:50 PM1/15/14
to tas...@googlegroups.com
Most regex don't allow variable length lookbehind strings.

Matt

Pent

unread,
Jan 16, 2014, 2:37:02 AM1/16/14
to tas...@googlegroups.com

I think it failed because it made the capture group variable length, but that is speculation. 

I remember hitting that in specifying the regex for variable name matching. Limitation of
Android regex.

Pent
Message has been deleted

Nate French

unread,
Jun 3, 2014, 6:01:50 PM6/3/14
to tas...@googlegroups.com
"The maximum length of possible matches for look-behind patterns must not be unbounded." 
Source: http://developer.android.com/reference/java/util/regex/Pattern.html (section: Look-around assertions)

I think it's not due to a variable length, but rather an unbounded length.  The expression .*  or
.+ will match greedily (and .*? or .+? sparingly) off to an unspecified length.  By contrast, the expression .{1,10}? has a bounded length, variable from 1 to 10 characters.

Matt R

unread,
Jun 3, 2014, 10:27:26 PM6/3/14
to tas...@googlegroups.com
I can confirm that you can use "bounded" variable length expressions in regex in Tasker ... except you can't use repetition (curly braces) above 10 for some reason. Even a fixed, non-variable {11}. Strange...

Matt

Reply all
Reply to author
Forward
0 new messages