Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Regular Expressions
  4. Forming reguar expressions using a builder class?

Forming reguar expressions using a builder class?

Scheduled Pinned Locked Moved Regular Expressions
regexcomtutorialquestion
4 Posts 3 Posters 10 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Sander RosselS Offline
    Sander RosselS Offline
    Sander Rossel
    wrote on last edited by
    #1

    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).MatchEnd

    If Not Regex.IsMatch(TextBox1.Text, regEx.GetExpression) Then
    MessageBox.Show("This is not a valid email address")
    End If

    Does 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.

    L P 2 Replies Last reply
    0
    • Sander RosselS Sander Rossel

      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).MatchEnd

      If Not Regex.IsMatch(TextBox1.Text, regEx.GetExpression) Then
      MessageBox.Show("This is not a valid email address")
      End If

      Does 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.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      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/[^]

      Sander RosselS 1 Reply Last reply
      0
      • L Lost User

        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/[^]

        Sander RosselS Offline
        Sander RosselS Offline
        Sander Rossel
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • Sander RosselS Sander Rossel

          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).MatchEnd

          If Not Regex.IsMatch(TextBox1.Text, regEx.GetExpression) Then
          MessageBox.Show("This is not a valid email address")
          End If

          Does 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.

          P Offline
          P Offline
          PIEBALDconsult
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups