OG, as a follow up I spent a bit of time this evening using Expresso and I'm very impressed. Another tool I also use is RegexBuilder[^] (by Matt Jacobsen and Markus Renschler). While it's not a regex designer like Expresso it is an excellent parser-cum-tester.
You paste in or edit a regex string and you can create from 2 - 15 text lines. For example, I might create multiple lines showing variations of input text to be inspected. The moment you change the text or the regex you get an immediate colour change of the success or failure of the validation status on a particular line of sample text. That's useful if you are interested in specific strings. It's free which is nice.
I have a paid-for utility as well. So the three complement each other. For designing expressions, Expresso will be my striker, RegexBuddy my midfielder and RegexBuilder in defence.
If there is one thing more dangerous than getting between a bear and her cubs it's getting between my wife and her chocolate.
This is not a good regex task - it isn't strictly pattern matching, it's a counting job, which regex is pretty bad at.
While you can do it it would be horribly complex, and if you decided at a later date that you wanted to include special characters in there it would be a real PITA to maintain.
Instead, do it in code: Use two regexes - one to return all the digits, and one to return all the alpha characters. You then check that the length of both is greater than zero.
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
The best suggestion I have is to find (or invent) some interesting problems, then play with Expresso to solve them (in as many ways as you can think of).
Having said that, remember that regex is not the universal solution for string processing. There are many cases where regex is not the appropriate tool.
(Remember the old saw "When all you have is a hammer, everything looks like a nail." Don't let regex become your hammer.)
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
i am doing a project, i want to match a string with regex which will match the whole string and it dosent allow two white spaces concerrently on after the other and also it dosent allow white spaces at starting and ending of string, any number of white spaces is allowable but not concurrently one after the other
I want to:
1) count the number of round brackets '(', I expect as result 2
2) get the text inside, I expect "\"Happy"\", which appear in console output as "Happy"
No idea for 1. I try the following for 2
string k = Regex.Match(s1,@"\((\w+)\)").Groups.Value;
But It fails in understanding the \" character
Last Visit: 31-Dec-99 19:00 Last Update: 26-Nov-21 20:01