Okay, so I'm having trouble again with a few regular expressions.
I've made myself a miniconsole and placed it inside a container to capture tells and it's working. I've echoed to it, made it capture other articles, but for some awful reason I just cannot seem to find the right way to capture my tells. As far as I can tell it should go like this:
Some replies to you, 'Hello!'
^(w.+) replies to you, '(w.+)'
Some tells you, 'Hello there!'
^(w.+) tells you, '(w.+)'
Someone With A Big Name, That Includes Comas tells you, 'Hello!'
^(w.+) tells you, '(w.+)'
Someone With A Big Name, That Includes Comas replies to you, 'Hey there!'
^(w.+) replies to you, '(w.+)'
I assumed it would be the same for either and capture everything before the word replies and tells as a wildcard (If that's the correct way to note it.)
Guidance?
Capturing Various Tells With Regular Expressions
Re: Capturing Various Tells With Regular Expressions
So, to capture multiple a "big name, that includes commas", you need to use this pattern: ([\w\s,]+)
To capture a regular name, you need to use this pattern: (\w+)
To capture assorted text between quotes, you need to use this pattern: '(.+)'
The pattern you have here, (w.+), would capture anything that starts with a 'w', followed by however many characters of any type until the rest of the pattern was found, the most such characters possible while still matching the overall trigger pattern.
So, I would use this as a pattern, to capture all of the above:
^([\w\s,]+) (tells|replies to) you, '(.+)'
To capture a regular name, you need to use this pattern: (\w+)
To capture assorted text between quotes, you need to use this pattern: '(.+)'
The pattern you have here, (w.+), would capture anything that starts with a 'w', followed by however many characters of any type until the rest of the pattern was found, the most such characters possible while still matching the overall trigger pattern.
So, I would use this as a pattern, to capture all of the above:
^([\w\s,]+) (tells|replies to) you, '(.+)'
Re: Capturing Various Tells With Regular Expressions
Was the w without the slash causing this? I'm vaguely aware that the \ denotes some type of special character or does it announce in the regex that it's code and not the beginning of the actual pattern I'm capturing?
Re: Capturing Various Tells With Regular Expressions
The \ denotes something special follows. \w indicates a "word" character, which is letters, numbers, or underscores. \s indicates white space characters, like spaces, tabs, etc.
Re: Capturing Various Tells With Regular Expressions
Thank you for this. I've read some guides, but they really over complicated it, at least for me. That makes a lot more sense.
- SlySven
- Posts: 1023
- Joined: Mon Mar 04, 2013 3:40 pm
- Location: Deepest Wiltshire, UK
- Discord: SlySven#2703
Re: Capturing Various Tells With Regular Expressions
BTW that is a lower case 'w' - the upper case means the opposite i.e. anything which isn't a word - the same is true of others. One good site to play with this sort of thing is regex101.com...!