Re: Regular expression for punctuation

Discussion in 'ASP .Net' started by Chris R. Timmons, Jul 10, 2003.

  1. Chris Leffer <> wrote in
    news::

    > Hi Chris,
    >
    > I looked at the site. Very good information, thanks.
    >
    > But I tried to use the \p in my expression and it did not work.
    > I finished the following expression that I use with a regular
    > expression validator control:
    >
    > [A-Za-zÀ-ú0-9 \p{Po}]*
    >
    > I need to accept letters, accented letters, digits, spaces and
    > punctuation characters. If I type any kind of character as < or
    > > for example, all of them are accepted. Can you see what is

    > wrong with this expression?


    Chris,

    The * quantifier on the end means "zero or more". The short answer
    is to use the + quantifier (one or more) instead.

    The long answer is that the * quantifier can sometimes cause strange
    problems because it always matches. When using your regex in a
    operation to replace the > characters in string a>b>c with an x, I
    received an incorrect result of xx>xx>xx. Changing the * to a +
    caused the replacement regex to operate correctly and return a value
    of x>x>x.


    Hope this helps.

    Chris.
    -------------
    C.R. Timmons Consulting, Inc.
    http://www.crtimmonsinc.com/
    Chris R. Timmons, Jul 10, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris Leffer

    Regular expression for punctuation

    Chris Leffer, Jul 9, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    412
    Chris Leffer
    Jul 9, 2003
  2. VSK
    Replies:
    2
    Views:
    2,261
  3. DBLWizard
    Replies:
    10
    Views:
    733
    Brock Allen
    Apr 2, 2005
  4. =?iso-8859-1?B?bW9vcJk=?=

    Matching abitrary expression in a regular expression

    =?iso-8859-1?B?bW9vcJk=?=, Dec 1, 2005, in forum: Java
    Replies:
    8
    Views:
    823
    Alan Moore
    Dec 2, 2005
  5. GIMME
    Replies:
    3
    Views:
    11,909
    vforvikash
    Dec 29, 2008
Loading...

Share This Page