Where can I find a list of what regex... bits, match to what text?
Since that probably didn't make sense, I know that \d+ is a number \w+ is a word. I want to know what else I can match.
Also, how do I tell my trigger that a certain character is not part of a regex? If there's a number in parentheses in what I want to match, how do I let it know to ignore the outside set? Say I want to match (63) and have it capture the 63. ((\d+)) doesn't seem like it would work.
Newb question
Re: Newb question
That was exactly what I needed!!! Thankyouthankyouthankyou!
Re: Newb question
\((\d+)\) will work. \ before a special character will ignore it, so \( will match the literal opening bracket.
Re: Newb question
I have another newb regex question, so I decided to revive this thread instead of creating another similar one.
What's the difference between (\w+) and (\w*)? I know that 'w' is for words. I'm more confused concerning the '+' and '*'. Looking at a perl regex tutorial, it said that they specify repetition and '*' matches 0 or more times and '+' matches 1 or more times. I'm not really sure what that explanation means, nor when it is best to use one or the other.
Thanks for your assistance!
What's the difference between (\w+) and (\w*)? I know that 'w' is for words. I'm more confused concerning the '+' and '*'. Looking at a perl regex tutorial, it said that they specify repetition and '*' matches 0 or more times and '+' matches 1 or more times. I'm not really sure what that explanation means, nor when it is best to use one or the other.
Thanks for your assistance!
Re: Newb question
\w* will match "", "a", or "aba"
\w+ will match all of those except for "" - it needs at least 1 word-type character
\w+ will match all of those except for "" - it needs at least 1 word-type character
Re: Newb question
And so you can use \w* for capturing optional words/alphanumeric char. And use \w+ for words/alphanumeric char which absolutely must be there.
(\w+) is here
Would match on
Demonnic is here.
But would not match on
is here
even with the space in front of it.
(\w*) is here
Would match on both of those, but would require the space in front of "is here" ... a truly optional regex would be
(\w*)\s*is here
So that the space is also optional.
(\w+) is here
Would match on
Demonnic is here.
But would not match on
is here
even with the space in front of it.
(\w*) is here
Would match on both of those, but would require the space in front of "is here" ... a truly optional regex would be
(\w*)\s*is here
So that the space is also optional.
Re: Newb question
Ok, thanks! That definitely cleared things up!
Re: Newb question
in Demonnic's example, the best way to do that last regexp would probably be:
because ? matches 1 or 0 occurrences. As Demonnic wrote it, it would also match this:
Which may not be what you're looking for.
Code: Select all
\w*\s?is here
Code: Select all
Demonnic is here
Re: Newb question
This is true.. I was just focusing on the difference between + and *. heh