Hello everyone,
I want to capture word "assignment" only when it is found at the begining of line and line ends after that word.There can be zero or more space characters after "assignment" word and characters like : or # or - might come.
For example following lines should match
Assignments
or
Assignments :
or
assignments
Where as, following string should not match
The details of various assignments that I have ...
I get following line from one file which contains two occurances of "assignment" word.
Ab Initio\r\r\a\r\a\v\r\r\fAssignments\rThe details of the various assignments that I
I wrote following regular expression, but it is not able to capture anything :
^Assignments(\s|:|-|#)*?$
When I write regex like below, both the occurances of "assignment" get selected :
Assignments(\s|:|-|#)*?($)?
Any guesses? What should I do? I am using C# for this.
My C# code is as follows :
RegEx x = new Regex(@"^Assignments(\s|:|-|#)*?$", RegexOptions.IgnoreCase | RegexOptions.Multiline);
output = x.Replace(inputText, "@@@@@@@@@@@@@@@@\r\n<project_details>$&");
if (x.IsMatch(inputText))
{
Match m = x.Match(inputText);
Console.WriteLine("\n\n\t~~~~~~~~~~ match found ~~~~~~~~~~~");
Console.WriteLine(m.Index +" : " + m.Value);
Console.WriteLine("\n\n\n\n" + output);
}
else
{
Console.WriteLine("$$$$$$$$$$$$$ no match %%%%%%%%%%%%%%");
}
Just now I re checked my input string. Original lines in file is as follows :
Assignments
The details of various assignmenths that I ...
But when I load filestream into one string variable, I get same line like this :
\r\r\a\r\a\v\r\r\fAssignments\rThe details of the various assignments that I
Anyone knows what is happening? How should I formulate my regular expression? Please help !!!!