Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Voxera115854yWhat ... is ... that ... ?
Looks like its matching characters and assigning them to named captures.
But ... why .., -
@magicMirror
> The post looks exactly as it is supposed to look - there are no problems with its content. -
@Voxera That’s exactly what it’s doing. (Because I’m working on writing a program to take a regular expression and output a more human-readable string description of what the regular expression is matching as a code comment)
-
@010001111 I was going to write a very sarcastic response, but realize that this is a stressful time for a lot of folk and for all I know, you’re trying to be well-meaning.
Yes, I know things like that exist. It would be hard to not know that, considering the amount of research that goes into writing a program like this. I’m working on a program that adds these descriptions as code comments, to make it easier for future developers working on a project to understand what’s going on, since regular expressions are magic for a lot of developers. -
@AmyShackles as a vivid regex enthusiast I have to mention that although it sounds like a good project and I don’t want to stop you from it, I’m afraid that longer regexes simply shouldn’t exist, as programmer code at least.
You may want to merge programmatically multiple regexes, but the longer one regex is, the harder it is to debug, no matter what comments or documentation there is.
E.g. when Mail checking, you can simply explode the string into an user and domain signature and test both of them separately, instead of making a huge regex that matches everything and can’t be easily extended if the spec will do things like, oh say... tld using emojis -
I raise you a transpiler regex: /val|var|[1-9]{1,32}|\+|\-|\*|s\/s|>>|=|;|(["'])(?:(?=(\\?))\2.)*?\1|print\(|log\(|sqrt\(|input\(|strToArray\(|httpGet\(|if\(|else|{|}|s==s|s>=s|s<=s|s>s|s<s|s&&s|\|\||!|;|\(|\)|\[|\]| |\w+/gi
-
@PrivateGER So the capture group containing the backslash and the '?' quantifier inside of the positive lookahead inside of a non-capturing group using a back reference to aforementioned capture group -- that's to ensure you either have 0 backslashes or two? Why use a back reference at that point at all, why not just group two backslashes together with a '?' quantifier?
(Unless I'm misparsing this bit /(?:(?=(\\?))\2.)/ ) -
Voxera115854y@010001111 and you should never use a big regex to check an email :)
Any checking beyond that it has an @ and maybe something more or ultimately going to reject valid email addresses while possibly allowing invalid.
With idn and the over 20 different rfc’s governing email address format there are just to many alternatives.
You could probably split the email up in parts and then by part test it against multiple regexes to find the right one.
But I would recommend either buy a component or ditch validation and just require a test email be sent with a link, this not only validated the format but that its actually a working email belonging to the user, thing no regex “hopefully” will be able to do.
Related Rants
*maniacal laughter*
/(?<digit>\\d)|(?<non_digit>\\D)|(?<alphanumeric>\\w)|(?<non_alphanumeric>\\W)|(?<whitespace>\\s)|(?<non_whitespace>\\S)|(?<horizontal_tab>\\t)|(?<carriage_return>\\r)|(?<linefeed>\\n)|(?<vertical_tab>\\v)|(?<form_feed>\\f)|(?<backspace>\[\\b.*?\])|(?<NUL>\\0)|(?<control_character>\\c[A-Z])/g;
... I need to sleep
rant
sleep deprivation
regex