Forming reguar expressions using a builder class?
-
I just started reading about regular expressions and they seem quite complex. So I am going to try really hard to understand them. But I am worried that if I ever want to use regular expressions at work I need to present a format that everyone could understand. So I was thinking something like:
Dim regEx As New RegExBuilder
' The entire code is pretty much self describing I think.
' Text must match from the start
' The text must start with plain text, that must be followed by a @, which must be followed by
' another sequence of text, which must be followed by a . and a 2 or 3 character domain (example: .nl or .com)
' This must be the entire text.
regEx.MatchStart.SequenceOfText.MatchChar("@").SequenceOfText.MatchChar(".").SequenceOfText(2, 3).MatchEndIf Not Regex.IsMatch(TextBox1.Text, regEx.GetExpression) Then
MessageBox.Show("This is not a valid email address")
End IfDoes that exist or am I saying something really stupid? :laugh: I was thinking of making something like that myself, just for fun and to get to know regular expressions myself. If I succeed and people are interested I could probably put it in an article here on CP too :)
It's an OO world.
-
I just started reading about regular expressions and they seem quite complex. So I am going to try really hard to understand them. But I am worried that if I ever want to use regular expressions at work I need to present a format that everyone could understand. So I was thinking something like:
Dim regEx As New RegExBuilder
' The entire code is pretty much self describing I think.
' Text must match from the start
' The text must start with plain text, that must be followed by a @, which must be followed by
' another sequence of text, which must be followed by a . and a 2 or 3 character domain (example: .nl or .com)
' This must be the entire text.
regEx.MatchStart.SequenceOfText.MatchChar("@").SequenceOfText.MatchChar(".").SequenceOfText(2, 3).MatchEndIf Not Regex.IsMatch(TextBox1.Text, regEx.GetExpression) Then
MessageBox.Show("This is not a valid email address")
End IfDoes that exist or am I saying something really stupid? :laugh: I was thinking of making something like that myself, just for fun and to get to know regular expressions myself. If I succeed and people are interested I could probably put it in an article here on CP too :)
It's an OO world.
Naerling wrote:
just started reading about regular expressions and they seem quite complex
Some resources for you ... RegEx Tutorial http://en.kerouac3001.com/regex-tutorial-8.htm[^] On-Line Application http://www.gskinner.com/RegExr/[^] a downloadable desktop version is available. Note the right hand panel for samples etc. Video Tutorial series using said RegExr application http://net.tutsplus.com/tutorials/php/regular-expressions-for-dummies-screencast-series/[^]
-
Naerling wrote:
just started reading about regular expressions and they seem quite complex
Some resources for you ... RegEx Tutorial http://en.kerouac3001.com/regex-tutorial-8.htm[^] On-Line Application http://www.gskinner.com/RegExr/[^] a downloadable desktop version is available. Note the right hand panel for samples etc. Video Tutorial series using said RegExr application http://net.tutsplus.com/tutorials/php/regular-expressions-for-dummies-screencast-series/[^]
Thanks! Those vids are great. I just watched the first one and I already feel like an expert! :laugh: That website is very useful too. Article good too... It's all good :thumbsup: They are really going to help me learning good and fast :)
It's an OO world.
-
I just started reading about regular expressions and they seem quite complex. So I am going to try really hard to understand them. But I am worried that if I ever want to use regular expressions at work I need to present a format that everyone could understand. So I was thinking something like:
Dim regEx As New RegExBuilder
' The entire code is pretty much self describing I think.
' Text must match from the start
' The text must start with plain text, that must be followed by a @, which must be followed by
' another sequence of text, which must be followed by a . and a 2 or 3 character domain (example: .nl or .com)
' This must be the entire text.
regEx.MatchStart.SequenceOfText.MatchChar("@").SequenceOfText.MatchChar(".").SequenceOfText(2, 3).MatchEndIf Not Regex.IsMatch(TextBox1.Text, regEx.GetExpression) Then
MessageBox.Show("This is not a valid email address")
End IfDoes that exist or am I saying something really stupid? :laugh: I was thinking of making something like that myself, just for fun and to get to know regular expressions myself. If I succeed and people are interested I could probably put it in an article here on CP too :)
It's an OO world.
Naerling wrote:
I was thinking of making something like that myself
Well, go, man, go! It looks like a fun exercise. You could certainly start with just the parts you need now and add more as needed. You may need to leave out more "advanced" stuff like nested groups, but just encapsulating the most basic functionality may be of use to many.