So at some point in our lives we've all had to encounter the wonders of Regular Expressions (Regex). If you don't know what Regex is in short terms...
For further actions, you may consider blocking this person and/or reporting abuse
"I don't think anybody likes writing it."
=> I do !
RegEx are life, RegEx are everything !
Same. Writing a complex RegEx is like a mini-game.
Hey buddy!!!
Can you please suggest me a good tutorial to learn regex??
Regex has minor different syntax's for every language. Personally I learnt it from this website regular-expressions.info/tutorial....
I was looking for Java RegEx.
Getting prompt suggestions from experts is the beauty of this site!!
Thanks a lot George.
May code bless you... 🙂
rubular.com is another great resource. The basics are going to be pretty much the same from language to language.
I have always turned to regexr.com/ when I have needed help with RegEx.
Not a tutorial perse, but this puzzle-game is quite a fun practice for them: regexcrossword.com
regex101.com/
I don't like this syntax. It seems overly bloated compared to the equivalent regex. Your example also doesn't include grouping, which is vital to extracing information from regex parsed strings. It also doesn't show how counted repitions, like in the regex graphic, would be used.
I'm afraid this would be ridiculously verbose for non-trival expressions.
Personally I kind of see it per project, how much it'll be used and on the language in general. For some minor usage of it without having to make something overly complicated I find this would be perfect for what is needed. However I do agree with your points, some of my projects (Java and C# specifically) I've stuck with standard Regex due.
Perhaps there is a happy middle ground. Certainly when I'm doing basic matching I definitely prefer functions like
endsWith
,contains
andstartsWith
compared to the equivalent regex.Don't use the email regex given in example, this one is wrong.
Here are some valid email address according to RFC822 that will not match the regex :
me@example.museum
(the tld contains 6 characters)John Smith <john@smith.com>
(Yes, you can put a name in front of an enclosed email address like that)Some times, using RegEx (or VerbalExpression) is not appropriate. In this case, you should probably write a parser. Here is the implementation of this parser in go : golang.org/src/net/mail/message.go...
A few months ago, I needed a really complicated Regex for a project that I was working on. After struggling for a very long time with the syntax, I ended up writing a small library to generate the Regex for me. The thing is: I never used it again, so I never got to write a decent documentation.
Using my library, your example would look like that:
If you wanna check it out, take a look here: github.com/danielbastos11/frogjs
The test fold is quite complete (I'm surprised, actually).
This is awesome! How is this not a billion times more popular than it is?? Thanks for sharing!
I think this is a very bad idea, it is much better to learn regex from regular-expressions.info.
I think having a single line complex regex is a code smell. It is a much better approach to build it from sub-patterns or use multiple regex patterns or don't use regex at all. I Have a small example as evidence (note that the code is not tested or not even written in an editor):
Using a single complex pattern (common golden hammer mistake):
Using multiple small patterns in combination with language features:
Building the pattern from sub-patterns:
Wow man! you've made my life 100x easier!
Thanks
Man I freaking hate regex because it makes me feel so dumb. No matter how much I try to learn it, I never seem to really understand it. I hate it lol