For me it is the most important question about Regex, may be for some others too.
I rarely use regular expressions. But whenever I have to tackle with a bit complex regular expression i find even hard to find the words for search.
And except regex I can not think any other thing in programming for which I could be stuck to search. And lot of problems of those domains, where your knowledge/skills are too little are solved easily by little search. But unable to do this thing in case of regex
For example I have a valid expression
Select * from sale where Quantity < '10' and Date <= curdate() and
Date >= date_sub(curdate(), interval 3 month)
I have allowed user to modify this query but after modification I want to verify that user has chnaged nothing except relational operators and values following the relation operators. Regex would be something like
Select .+ from sale where Quantity [<|>|=|(<=)|(>=)] .+ and Date
[<|>|=|(<=)|(>=)] .+ and Date [<|>|=|(<=)|(>=)] (string not containing any join)
This specific question is already solved. Actual question is general about Regex.
I can think only two solutions for problems like this
- To have a good knowledge/skills/concepts of regular expression
- Ask on forum.
In all other cases I usually find help from search without reading tutorials etc, except some very typical/unique/new type of technique. But search does not seem solid solution in case of regular expressions because they are mostly unique. Is it? How?
It does not mean I am against reading tutorials. I do myself and perhaps more for Regex than other things (Because we had not read them enough in our course) but still face problems
You can ask questions about programming problems easily because you know the basic concepts: Loops, functions, lists, hashes, modules, strings, input, output, files – you know the basic vocabulary and therefore you know how to ask a programming question.
But you didn’t get this knowledge from nothing – at one point you had to learn the basics. This is easy to forget because you take them for granted.
With regular expressions, there are many new concepts to learn, a new vocabulary. Suddenly, there are new words like groups, alternations, anchors, lazy and greedy quantifiers, lookaround, atomic grouping, captures and much more…and you won’t get around learning that new vocabulary so you can ask meaningful questions.
It’s not that difficult to get yourself acquainted with the basic concepts. Use a decent tutorial (http://www.regular-expressions.info), play with regexes in your favorite language, use online regex testers…Personally, I learned nearly everything I know about regexes from using RegexBuddy on a daily basis. And from StackOverflow.
You can ask basic regex questions here, there are lots of them everyday. And usually only those get downvoted where it’s obvious the poster hasn’t put a shred of effort into them.