Hi Folks,
I've used regex a tiny bit and am trying to learn more, for a specific project I'm working on. From what I've read, the version of regex that ahk recognizes is fairly similar to other varieties, and is based on Perl. There are a couple free tools I've found for testing regexs I make. Of course there's Regex Tester by Robert Ryan, which is designed for ahk regex testing. But there are a couple of others out there, like Expresso and The Regex Coach.

I noticed that the expression for case-insensitivity is "i)" without quotes, at the beginning of the regex. This works for ahk, but Expresso says it's an error. So that's at least one difference. Are there likely to be lots of other differences too, or is it safe for me to use this as a learning tool? Also, there are a few regex books to be had at it-ebooks.info. But it's the same question: Is it safe to learn from those, or should I just stick to the Quick Reference guide in the AutoHotkey documentation?

Any other recommendations for learning?
Thanks in advance, for any tips.

EDIT: Actually, I see that Expresso has a setting to choose between C#, VisualBasic, Managed C++, or C++/CLI. Maybe one will be closer than the others? I know that AHK code, in general, pulls from several different languages....

I also like regex101.com. It allows you to save your regex and share it with others: https://regex101.com/r/vK0bJ8/1 The explanation it provides is pretty good too.
Note that options are listed in a separate box, which differs from the AHK syntax.

In terms of references, the majority of the time I use the help file's Quick Reference. There are some things found in the AHK help file Quick Reference that are unique to AHK. For example the "S" (study) option.

Sometimes a web-search works well if you are doing something complicated. Even if you find examples that aren't PCRE (perl compatible regular expressions), the differences are usually minor.

Use regex in whatever tools or languages you have a purpose for. Even if they are different flavours of regex, they're all based on the same concepts and generally have similar syntax.

From what I've read, the version of regex that ahk recognizes is fairly similar to other varieties, and is based on Perl.

You mean PCRE. Yes, it is similar to other varieties of regex, but PCRE is also very widely used directly by other programs and some languages. For instance, Notepad++ and PHP use PCRE.

I noticed that the expression for case-insensitivity is "i)" without quotes, at the beginning of the regex. This works for ahk, but Expresso says it's an error. So that's at least one difference.

The "options)" prefix is unique to AutoHotkey - other utilities or languages will have their own ways of specifying the same options, like check boxes or alternative syntax. Perl and Javascript use /pattern/i for regex literals. Forward-slash is used in place of quote marks.

Some of the option letters are copied directly from PCRE, and some of those correspond to Perl option letters. PCRE also supports changing them within the pattern (and therefore so do AutoHotkey and Notepad++):

Actually, I see that Expresso has a setting to choose between C#, VisualBasic, Managed C++, or C++/CLI.

What's the difference? Those are all .NET based. .NET has its own variety of regex, which as far as I'm aware, is the same across all .NET languages. I assume that Expresso itself is written in a .NET language, but PCRE can be used from .NET too...

Are there likely to be lots of other differences too[...]?

All of the syntax described in the PCRE manual should work. There are other differences between PCRE and .NET regex. I suggest you google for a comparison.

Thanks guys, for the tips. Ultimately I guess it's like Lexikos said, you just have to use it to learn it. The various tools are nice though, because you can immediately see what all the different matches are at once. Above, I mentioned Expresso, which is nice because of its "builder." I did notice in the manual though, that it's .net based. Regex Coach is PCRE based, but I do have to say that the online tools you guys suggested do provide nice descriptive info. Incidentally, searching for a comparison of the different flavors of regex quickly became overwhelming. It's all good though. I'm learning as I go. I'm also reading Jack Dunning's AutoHotkey Regex book on my Kindle... It's pretty good.

Kon, I noticed that your use of RegExMatch differs from what is shown in the ahk documentation:RegExMatch(TestText, "[0-9]+:[0-9][0-9]", Match)
versus:FoundPos := RegExMatch(Haystack, NeedleRegEx [, UnquotedOutputVar = "", StartingPosition = 1])
It surpized me, because the docs don't list FoundPos := as optional. (They're not in brackets.)

I'm glad you posted it, because this is exactly what I want to do! (Extract time and date from a selected bit of text.. I don't really even care where its position is.)

It surpized me, because the docs don't list FoundPos := as optional. (They're not in brackets.)

Optional parameters are typically enclosed in brackets in the documentation, but it's not an optional parameter. It's not a parameter at all.

The return value is not marked optional in any way because that's just how functions/expressions work. The function call and assignment are two separate operations. You don't have to assign the return value to a variable - you can pass it directly to another function or just discard it. FoundPos := is there just to give a more meaningful name than "return value", and let the user see at a glance what the return value means.

Do you guys know if anyone has attempted to make a regex tester that will accept variables? For example, in the regex window you might have:
===========================================================================
reWDay := "i)\b((Mon|Tue(s)?|Wed(nes|s)?|Thu(rs|r)?|Fri|Sat(ur)?|Sun))(day|d)?\b"
(%reWDay% next week|next week %reWDay%)
===========================================================================
The top line(s) would be like a "resource" for the bottom line. And the bottom line would be the actual regex.
Would be kinda' clever..
In another thread there was discussion of utilizing this technique of pre-defining segments of regex code so that my Alternations would be more compact and easier to deal with. The problem is that I can't easily test them on chunks of code in-bulk.

@jackdunning, I'm happy to see you posting here on the forum. I enjoy your blog posts a lot, and subscribe to the weekly digest.
I had not seen the RegEx post before, thanks.
Regards,
burque505
p.s. Looking forward to the next post in the LV Gui series.