AutoVoice Optional Named Group Regex Not Working

Discussion in 'AutoApps' started by Jmott, Aug 30, 2016.

  1. Jmott

    Jmott New Member

    Joined:
    Aug 30, 2016
    Messages:
    2
    Likes Received:
    0
    I am having a problem with some AutoVoice regex where I would like to make a named group optional. I currently have two profiles that are working for this, but I would ideally like them combined.

    Current regex:
    (?<action>lock|unlock|open|close) (?<door>all|front|garage) doors?
    (?<action>lock|unlock|open|close) (?<verb1>the|my|our) (?<door>all|front|garage) doors?

    All of the current regex works, I just want it to be a single profile. It will recognize:
    lock all doors
    lock front door
    lock my garage door
    unlock the front door

    This is what I think should work:
    (?<action>lock|unlock|open|close) (?<verb1>the|my|our)? (?<door>all|front|garage) doors?

    The ? after it is not allowing it to be optional, but otherwise still seems to work (if verb1 is not omitted). If this needs to always be multiple profiles, at least it works. But the number of profiles could be high depending on how many optional groups I am trying to use.
     
  2. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    9,479
    Likes Received:
    806
    I'm guessing it doesn't work because you have a space after (?<action>lock|unlock|open|close) and another one after (?<verb1>the|my|our)?, so if the second group doesn't exist in the sentence you said, it would have to match 2 spaces which wouldn't work :) You should probably include the second space inside the second group.
     
  3. Jmott

    Jmott New Member

    Joined:
    Aug 30, 2016
    Messages:
    2
    Likes Received:
    0
    I've added an extra question mark to make the second space optional. This seemed better to me than adding a space to the end of each word. This is now working, thanks.

    Working regex: (?<action>lock|unlock|open|close) (?<verb1>the|my|our)? ?(?<door>all|front|garage) doors?
     

Share This Page