TIP: Click on subject to list as thread! ANSI
echo: rberrypi
to: MARTIN GREGORIE
from: PANCHO
date: 2020-03-19 18:51:00
subject: Re: Regexes and C

On 19/03/2020 13:18, Martin Gregorie wrote:
> I spent more time than I should have yesterday trying to understand
> regcomp(), regexec() and regerror() well enough to validate a string
> containing an e-mail address string to make sure that: its structure is
> correct and neither the username nor the domain contains characters they
> shouldn't.
>
> The upshot was that I couldn't do it because I could not write a regex
> that would detect spaces in the address because apparently regcomp
> doesn't provide any way to anchor a regex to either end of a string, so I
> ended up with a negated regex that detects invalid characters in the
> string and hasn't a clue whether its syntactically correct:
>
> [^.a-zA-Z0-9@_-]
>
Not done regex in C recently but for me the trick has always been
getting the regex expression right. So I use an online tool to test
build regex expressions and see how they work.

I can't remember which one I used last, but something like this.



Much quicker than testing regex in your own code.

--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)

SOURCE: echomail via QWK@docsplace.org

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.