CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2006
    Posts
    326

    Regular expression pattern

    Hi, I want to write a pattern like this, plase correct it.
    Code:
    string key = "something";
    string pattern = key + "[^\\d]+.*";
    return Regex.IsMatch(string_value, pattern);
    I don't know how to add "@".
    Thanks.

  2. #2
    Join Date
    Feb 2011
    Location
    United States
    Posts
    1,016

    Resolved Re: Regular expression pattern

    So you want to match a pattern that starts with "something", contains at least one character that is NOT a digit (and the @ sign?) and then matches the rest of the string?

    If so, you are within a heartbeat of the solution:

    Code:
        string key = "something";
        string pattern = key + "[^\\d@]+.*"; //Change this line
        return Regex.IsMatch(string_value, pattern);
    Otherwise, I don't understand your question. Could you be more clear about what you want to do?
    Best Regards,

    BioPhysEngr
    http://blog.biophysengr.net
    --
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

  3. #3
    Join Date
    Jan 2006
    Posts
    326

    Re: Regular expression pattern

    I mean
    Code:
     string pattern = key + "[^\\d]+.*";
    or
    Code:
     string pattern = key + @"[^\\d]+.*";
    or
    Code:
     string pattern = key + @"[^\d]+.*";
    I want to match a pattern that starts with "something", contains at least one character that is NOT a digit and then matches anything.

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

Featured