How to find regex expression for a string
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: How to find regex expression for a string

  1. #1
    Join Date
    Jul 2011
    Posts
    8

    How to find regex expression for a string

    string str=@"MODULE: X
    AVAILABLE BYTES: 3121152
    MODULE: Y
    ABC
    DEF
    GHI34
    JKL.23
    AVAILABLE BYTES: 3121152";
    Regex moduleMemory = new Regex("MODULE: Y + .*AVAILABLE BYTES: ([0-9]*)", RegexOptions.Singleline);

    Match match = moduleMemory.Match(dataFromDevice);

    String mem = match.Groups[0].Value;
    I need to fetch MODULE: Y Available bytes but i guess regular expression is not proper.no match is found.can any one help me to find out regex expression?

  2. #2
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,101

    Re: How to find regex expression for a string

    Well, halfway

    Regex won't retrieve everything for you - it is just a string filtering system. On MSDN there are literally millions of examples on how to use RegEx. I also think you'll need to do some string manipulation, like for instance, use String.Substring to retrieve the "Module" part.

    I hope it helps

Tags for this Thread

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center