Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all articles
Browse latest Browse all 8156

Extracting Key Words Using Regular Expressions

$
0
0

Hi, Everybody...

I wish to write a small utility to read a C# file and find all instances of the following "pattern":

<anyCharacter(s)>[DbRecord("<dbRecordName>"<anyCharacter(s)>class<whitespace><className>:<anyCharacter(s)>

where

  • <anyCharacter(s)> is one or more characters, including whitespace, carriage return, linefeed, tab, etc.
  • <whitespace> is white space
  • <dbRecordName> is the DbRecord name I wish to extract
  • <className> is the class name I wish to extract
  • bold characters are literals, including the double quotes (") and colon (:)

For each instance, I wish to extract the DbRecord name and corresponding class name.

Questions:

  • What is the appropriate regular expression?
  • How would I iterate each instance and extract the DbRecord name and correspondingclass name?  Would the results be returned as an ArrayList or some other IEnumerable element?

Please advise.

Thank-you!


Viewing all articles
Browse latest Browse all 8156

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>