Regex
Example for c++ function
const string FUNCTION_PATTERN
= @"(?<returnType>[a-z|A-Z|0-9]+)
(?<functionName>.*)\(\s*(?<parameters>([a-z|A-Z]+
[a-z|A-Z|0-9]+\s*,?\s*)*)\);?\r?\n?";
Regex functionRegex
= new Regex(FUNCTION_PATTERN, RegexOptions.Multiline);
MatchCollection matches =
functionRegex.Matches(source);
object creation
List<string> result =
new List<string>();
reference variables
object copying
String copyOfWord =
(String)word.Clone();
access specifier on every
function/attribute/property
private int x;
public int X
{
get {
return x;
}
set {x =
value;}
}
foreach (Match match in matches)
{
static
data members & properties
private static int x;
public static int X
{
get {
return x;
}
set {x =
value;}
}
string[] sourceLines =
source.Split("\r".ToArray());
//remove the leading
and trailing whitespace from all strings in the
array
sourceLines =
sourceLines.Select(line =>
line.Trim()).ToArray();