find() finds the next match of the entire regex from the Search field.
If you have the string "4-1-2013 07:46:23 Team X:Team Y:45-70 Final", you will get 8 matches for the regex "\d+". But I only want the scores, so I'd use the regex ":(\d+)-(\d+)" expecting 2 matches, 45 and 70, instead you get ":45-70". (If you forgot the colon, you would get "4-1" and "45-70".)
The groupCount/group(int) methods would have given the expected results, but all the regex grouping rules could make this a newb/novice nightmare. Another option like "Return Regex groups" would be needed to differentiate between using find() and group(int). [Note: group() returns everything matching the entire regex, grouped or not.]
Cool tidbit 1: You can play with grouping to modify a string. In the replace field, groups can be referenced using $1, $2, etc. (group(int)). $0 is the same as group(). So, you could translate text into simple pig latin using "(\w)(\w+)" as the search and "$2-$1ay" as the replace.
Excuse my regexs. It's late. I'm tired. There are errors, but I'm not fixing them.
Also, there is still more not covered here, code-wise... and there is always more to learn about regex.
I also think it's a problem with the group function.
--
You received this message because you are subscribed to the Google Groups "Tasker" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tasker+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Most of the power comes from the ability to match groups. Reading the documentation I initially thought the match variable would be all the marched groups.
Text surrounding the groups is only normally used to place the groups the correct context for the match. Accessing all the matched text is not normally of interest.
By placing part of a regular expression inside round brackets or parentheses, you can group that part of the regular expression together. This allows you to apply a quantifier to the entire group or to restrict alternation to part of the regex.
In this sense, I do believe it complies with the norms of regex use based on your input and result.
Thanks for looking at this. But my point is that tasker seems to ignore ALL groups not just sub groups. Take a look at the screen shot below (the match is stirred in%result).
The group is ignored, only the matched text is stored.
Thanks for looking at this. But my point is that tasker seems to ignore ALL groups not just sub groups. Take a look at the screen shot below (the match is stirred in%result).
The group is ignored, only the matched text is stored.
This is the way Tasker regex is documented and expected to work.
Tasker is a great program and document everything it does is a mammoth task (no pun intended) in itself but I don't think the following is clear, it barely makes sense because the named parts of the dialog aren't marked in a consistent way (Store Matches In, variable, Search):
"Store Matches In specifies an array variable in which each successive part of the variable which matches the *whole* Search parameter is stored."
Perhaps italics or bars would make it clearer that labels in the form are being referenced:
"|Store Matches In| specifies an array variable in which each successive part of the |Variable| which matches the *whole* |Search| parameter is stored."
Peter
This is the way Tasker regex is documented and expected to work.
Matt
--
You received this message because you are subscribed to a topic in the Google Groups "Tasker" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tasker/PVtwyQV9An0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tasker+un...@googlegroups.com.
Visit this group at http://groups.google.com/group/tasker.
For more options, visit https://groups.google.com/d/optout.