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. C#
  4. Regular Expression

Regular Expression

Scheduled Pinned Locked Moved C#
regex
3 Posts 3 Posters 0 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.
  • V Offline
    V Offline
    vuthaianh
    wrote on last edited by
    #1

    How could i validate a unicode string Thanks

    S 1 Reply Last reply
    0
    • V vuthaianh

      How could i validate a unicode string Thanks

      S Offline
      S Offline
      sgatto159
      wrote on last edited by
      #2

      hope this helps (go to "Validating Unicode Characters"): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag2/html/paght000004.asp[^]

      E 1 Reply Last reply
      0
      • S sgatto159

        hope this helps (go to "Validating Unicode Characters"): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag2/html/paght000004.asp[^]

        E Offline
        E Offline
        eggie5
        wrote on last edited by
        #3

        Good find. " Validating Unicode Characters Use the following code to validate Unicode characters in a page. using System.Text.RegularExpressions; . . . public class WebForm1 : System.Web.UI.Page { private void Page_Load(object sender, System.EventArgs e) { // Name must contain between 1 and 40 alphanumeric characters // and (optionally) special characters such as apostrophes // for names such as O'Dell if (!Regex.IsMatch(Request.Form["name"], @"^[\p{L}\p{Zs}\p{Lu}\p{Ll}\']{1,40}$")) throw new ArgumentException("Invalid name parameter"); // Use individual regular expressions to validate other parameters . . . } } The following explains the regular expression shown in the preceding code: ^ means start looking at this position. \p{ ..} matches any character in the named character class specified by {..}. {L} performs a left-to-right match. {Lu} performs a match of uppercase. {Ll} performs a match of lowercase. {Zs} matches separator and space. 'matches apostrophe. {1,40} specifies the number of characters: no less than 1 and no more than 40. $ means stop looking at this position. " /\ |_ E X E GG

        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