RegExPlus

Start position

By specifying a start position, you can check for matches of the regex starting at positions other than the begining of the text.

Check all matches

The following task can be used to find all matches of a regex.

Steps to import the task into Tasker

  1. Download RegExPlus_Check_Matches.tsk.xml
  2. Tasker should offer to open the file for you. If not, you can manually import it by downloading the file and opening it.
  3. In Tasker, press and hold the "Tasks" tab and select import
  4. Select RegExPlus Check Matches
  5. You can now run the task and adjust it to fit your needs

The task works by checking for matches and when one is found, it checks for another match after the first match's end. It repeats this until no more matches are found.

Example task details

RegExPlus Check Matches

  1. Variable Set
    • Name: %start_index
    • To: 0
    • (initializes start index to beginning of text)
  2. Variable Set
    • Name: %text
    • To: a b cd efg hi
    • (sets text to search)
  3. RegExPlus
    • Configuration:
      • Variable: %group
      • Pattern: \w+
      • Text: %text
      • Start position: %start_index
    • Timeout (Seconds): 2
    • Label: start
    • (searches text for one or more word characters, starting at the specified position)
  4. If [ %group_end Set ]
  5. Flash
    • Text:
      Match: %group
      Start: %group_start
      End:   %group_end
    • Long: On
    • (outputs matched text and start / end positon)
  6. Variable Set
    • Name: %start_index
    • To: %group_end
    • (sets to start the next search at the end of the current match)
  7. Variable Add
    • Name: %start_index
    • Value: 1
    • If [ %group_start = %group_end ]
    • (handles empty, 0-length, matches by incrementing the start index)
  8. Goto
    • Type: Action Label
    • Label: start
    • (checks for the next match, repeating until there is no next match)
  9. End If