Regular expression for punctuation

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Regular expression for punctuation

    Hi.

    I am trying to define a regular expression that accepts letters and
    punctuation characters. I read something about Posix where I could use
    [:punct:] in order to accept all the punctuation characters, but I could
    not find how to add this to my expression. My expression is a simple
    [A-Za-z]. How can I make it accept all the punctuation characters also?

    Regards,

    Chris Leffer


    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Chris Leffer Guest

  2. Similar Questions and Discussions

    1. Regular expression help
      Hi, I'm pretty new to regular expressions. Before, I used to write long-winded and buggy segments of code with PHPs string functions to extract...
    2. help on regular expression
      Hi, I need some help on regular expression... i have following in variable $total_count $total_count = "##I USBP 000001 10:38:09(000)...
    3. regular expression help..
      On Thu, 28 Aug 2003 15:50:49 +0200 "point" <point@caanNOSPAMproduction.com> wrote: Don't cross post, it's considered bad form. /^-+$/ ...
    4. help with regular expression
      $text =~ /ABA.+ABA|ABA.+000/; $found = $&; -- Posted via http://dbforums.com
    5. Regular Expression....?
      Hi I am looking for the regular expression for validating the allowed file types to upload like files like "zip,pdf,doc,rtf,gif,jpg,png,txt"; and...
  3. #2

    Default Re: Regular expression for punctuation

    Chris Leffer <anonymous@devdex.com> wrote in
    news:uIEpkDkRDHA.2240@TK2MSFTNGP11.phx.gbl:
    > 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.
    [url]http://www.crtimmonsinc.com/[/url]
    Chris R. Timmons Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139