The + in regex is actually part of a subset of special characters (metacharacters) called quantifiers; in particular, it matches the preceding patternĀ¹ if it occurs one or more times in succession... eg:
/(asdf)+/i applied to
asdfasdfasdfg will match "asdfasdfasdf"
If you're curious about the other quantifiers, click the button below:
- ? - Matches preceding pattern 0 or 1 time (essentially making it optional)... eg: /colou?r/i will match both color and colour
- * - Matches preceding pattern 0 or more times - eg: /yeah*/i will match yea, yeah, yeahhhh, etc.
- {m}/{m,}/{m,n} - Matches the preceding pattern either: exactly m times; m times or more; or, at least m times but no more than n times... eg: /\d{3}/ will match exactly three digits, /d{3,}/ will match three or more digits, and /\d{3,7}/ will match at least three, but no more than seven digits.
It's important to note that quantifiers do not serve as a replacement for global matching (//g), as their reach is limited to the pattern they are quantifying... For example, if you tried to apply the same regex from above -
/(asdf)+/i to
asdfhelloasdfasdf, only the asdf before hello would be matched since hello breaks the pattern.
1. I hope my use of the term "pattern" here is clear, but of not, i can elaborate.
As for your other question, the // serve as delimiters in the regex to separate the match pattern from modifiers. As for why the first / is necesary when the second is used, I'm not entirely sure; depending on the language, different... let's just call them "premodifiers" - can be specified before the first / to change some function of the regex... The only one I know of in mIRC is "m", which allows you to set the delimiter... eg:
m~pattern~modifiersI asked on IRC about why the leading delimter is needed otherwise, because it's a good question, and while I don't remember the exact details, I was told that it's a syntax borrowed from other languages and is somewhat akin to the quotes of "some string" or 'some string'. (I'll try to provide a more detailed explanation tomorrow.)
For general regex understanding, a resource I reccomend is
regular-expressions.info - Not everything on it applies to mirc, but it's still a good guide.