[Chicago-talk] Help with Regex

Shlomi Fish shlomif at shlomifish.org
Sat Dec 24 11:08:23 PST 2022


Hi all,

On Sat, 24 Dec 2022 12:38:42 -0600
Alan Mead <amead at alanmead.org> wrote:

> Richard,
> 
> You need a good regex debugger. My favorite is:
> 
> https://regex101.com/
> 

In addition, I suggest writing a tests' suite:

* https://github.com/shlomif/what-you-should-know-about-automated-testing

* https://www.shlomifish.org/Perl-Begin/uses/qa/

> Your two new samples fail because there's a comma after state and your 
> regex doesn't allow that (you can add: ,* after ([A-Z]{2}).
> 
> I have no idea how regular your data are, but if these are random 
> addresses, you will have all kinds of problems. For example the two "\s" 
> below require exactly a single space character (no more, no less).
> 
> ^
> ([^,]+)
> *,\s*
> ([A-Z]{2})
> *\s*
> (\d{5}(?:-?\d{4})?)
> $
> 

-- 

Shlomi Fish       https://www.shlomifish.org/
https://github.com/shlomif/shlomif-computer-settings/ - my dotfiles

https://en.wikipedia.org/wiki/Evil redirects to XSLT.
    — https://www.shlomifish.org/humour/bits/facts/XSLT/

Please reply to list if it's a mailing list post - https://shlom.in/reply .


More information about the Chicago-talk mailing list