Regular Expression for single quote etc..

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sue

    #1

    Regular Expression for single quote etc..

    Hello

    I'm new to Regular Expressions..

    When the user types in a text box, I want the user to type only A-Z,
    a-z, 0-9, comma, dash, period, single and double quotes.

    How do I build such an expression.
    Thanks
    Sue..

  • Doug Bell

    #2
    Re: Regular Expression for single quote etc..

    Sue,

    Sub TextBox1_Keypre ss(By Val sender as Object, _
    ByVal e as KeyPressEventAr gs) Handles TextBox1.KeyPre ss

    Dim c as Char
    c=e.KeyChar
    If Not Char.IsLetterOr Digit(c) And Not c="." And Not c="-" _
    Or Char.IsControl( c) Then
    'Also look at Is Separator
    e.Handled = True

    End If

    End Sub

    Doug

    "Sue" <sue_kailasam@e arthlink.net> wrote in message
    news:1116363093 .050821.280610@ g47g2000cwa.goo glegroups.com.. .[color=blue]
    > Hello
    >
    > I'm new to Regular Expressions..
    >
    > When the user types in a text box, I want the user to type only A-Z,
    > a-z, 0-9, comma, dash, period, single and double quotes.
    >
    > How do I build such an expression.
    > Thanks
    > Sue..
    >[/color]


    Comment

    • stand__sure

      #3
      Re: Regular Expression for single quote etc..


      "Sue" <sue_kailasam@e arthlink.net> wrote in message
      news:1116363093 .050821.280610@ g47g2000cwa.goo glegroups.com.. .[color=blue]
      > Hello
      >
      > I'm new to Regular Expressions..
      >
      > When the user types in a text box, I want the user to type only A-Z,
      > a-z, 0-9, comma, dash, period, single and double quotes.
      >
      > How do I build such an expression.
      > Thanks
      > Sue..
      >[/color]

      I'd rather see you doing this in a "Handles TextBox1.KeyPre ss" manner using
      Char.IsLetterOr Digit(e.KeyChar ) for a-zA-Z0-9 and Char.IsPunctuat ion for the
      others (although you will have to refine this last a bit)

      to do this with a RegEx, you would do something like this (untested)
      [\w"-,'\.]+


      Comment

      • Sue

        #4
        Re: Regular Expression for single quote etc..

        Thanks for the reply..but the text box is a (.net) text box not a
        regular text box, which has the keypress event...in such cases how do I
        deal with it..

        stand__sure wrote:[color=blue]
        > "Sue" <sue_kailasam@e arthlink.net> wrote in message
        > news:1116363093 .050821.280610@ g47g2000cwa.goo glegroups.com.. .[color=green]
        > > Hello
        > >
        > > I'm new to Regular Expressions..
        > >
        > > When the user types in a text box, I want the user to type only[/color][/color]
        A-Z,[color=blue][color=green]
        > > a-z, 0-9, comma, dash, period, single and double quotes.
        > >
        > > How do I build such an expression.
        > > Thanks
        > > Sue..
        > >[/color]
        >
        > I'd rather see you doing this in a "Handles TextBox1.KeyPre ss" manner[/color]
        using[color=blue]
        > Char.IsLetterOr Digit(e.KeyChar ) for a-zA-Z0-9 and Char.IsPunctuat ion[/color]
        for the[color=blue]
        > others (although you will have to refine this last a bit)
        >
        > to do this with a RegEx, you would do something like this (untested)
        > [\w"-,'\.]+[/color]

        Comment

        • stand__sure

          #5
          Re: Regular Expression for single quote etc..

          "Sue" <sue_kailasam@e arthlink.net> wrote in message
          news:1116428923 .495280.37200@g 49g2000cwa.goog legroups.com...[color=blue]
          > Thanks for the reply..but the text box is a (.net) text box not a
          > regular text box, which has the keypress event...in such cases how do I
          > deal with it..[/color]

          I'm not clear on what you mean... are you referring to a textbox on a web
          form?


          Comment

          Working...