Results 1 to 3 of 3

Thread: [RESOLVED] Regex in Mono

  1. #1

    Thread Starter
    Frenzied Member tr333's Avatar
    Join Date
    Nov 2004
    Location
    /dev/st0
    Posts
    1,605

    Resolved [RESOLVED] Regex in Mono

    the following regex was posted in the vb.net forum for validading an e-mail address.
    VB Code:
    1. Dim regEx As New Regex("^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$", RegexOptions.IgnoreCase)

    when compiling with mcs (Mono), i get the following errors:
    (i don;t know how to create regex)

    ./Main.cs(76,27): error CS1009: Unrecognized escape sequence `\w'
    ./Main.cs(76,27): error CS1009: Unrecognized escape sequence `\.'

    anyone know how to fix this, or have a better option?
    CSS layout comes in to the 21st century with flexbox!
    Just another Perl hacker,

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Regex in Mono

    I don't know regular expressions at all, but to include a backslash \ character in a string you need to write it twice \\ as \ is used to denote special characters such as a null char \n.

  3. #3

    Thread Starter
    Frenzied Member tr333's Avatar
    Join Date
    Nov 2004
    Location
    /dev/st0
    Posts
    1,605

    Re: Regex in Mono

    thanks. that seemed to work.
    i guess i can also add @ to the front of the string (@"regex")
    CSS layout comes in to the 21st century with flexbox!
    Just another Perl hacker,

Posting Permissions

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



Click Here to Expand Forum to Full Width