Author Topic: Regex -- using curly brackets  (Read 1041 times)

0 Members and 1 Guest are viewing this topic.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2009
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Regex -- using curly brackets
« on: February 21, 2014, 06:14:05 PM »
The regex cheatsheet that is mentioned in the wiki and in the regex action descriptions (http://www.mikesdotnetting.com/Article/46/CSharp-Regular-Expressions-Cheat-Sheet) includes a couple of regular expression operators that use curly brackets:

Quote
{n}   n is a non-negative integer. Matches exactly n times. For example, "o{2}" does not match the "o" in "Bob," but matches the first two o's in "foooood".
{n,}   n is a non-negative integer. Matches at least n times. For example, "o{2,}" does not match the "o" in "Bob" and matches all the o's in "foooood." "o{1,}" is equivalent to "o+". "o{0,}" is equivalent to "o*".
{n,m}   m and n are non-negative integers. Matches at least n and at most m times. For example, "o{1,3}" matches the first three o's in "fooooood." "o{0,1}" is equivalent to "o?".


Is it possible to use those in Vox, given that VC uses curly brackets for its variables?
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Regex -- using curly brackets
« Reply #1 on: February 21, 2014, 09:49:37 PM »
You have to be careful.  If you try to use {2} in an expression, VC will try to replace it with payload 2.  If there is no payload 2 then it will leave it as is, so if you know your command is being executed without any payloads then you are free to use {2} in your expression.

If you know your command has a payload 2 attached to it, then you will need to avoid using the regex expression {2}.  This is relatively easy to do.

For example if you want to match exactly two digits using regex you can use any of the following patterns

Code: [Select]
\d\d

\d{2}

\d{2,2}

So you can use the first or the last option and just not use the middle one.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2009
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Regex -- using curly brackets
« Reply #2 on: February 21, 2014, 09:57:04 PM »
Okeydoke. Makes sense, thanks!
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)