.net - Probably simple regex search -


what regex find text#2? pattern it's first occurance of "z=" after c. text want rest of line after z=. i'm using regex in .net

a  x  b  x  z=text#1  x  c  x  z=text#2 

.*c.*z=([^\n]*).* 

you'll need turn on . matching newlines (regexoptions.singleline below).

here's c# code generated my regex tester:

using system; using system.text.regularexpressions; namespace myapp {   class class1     {       static void main(string[] args)         {           string sourcestring = "source string match pattern";           regex re = new regex(@".*c.*z=([^\n]*).*",regexoptions.singleline);           matchcollection mc = re.matches(sourcestring);           int midx=0;           foreach (match m in mc)            {             (int gidx = 0; gidx < m.groups.count; gidx++)               {                 console.writeline("[{0}][{1}] = {2}", midx, re.getgroupnames()[gidx], m.groups[gidx].value);               }             midx++;           }         }     } } 

Comments

  1. very informative blog and useful article thank you for sharing with us , keep posting Ruby on Rails Online Course

    ReplyDelete

Post a Comment

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -