I 开发者_Python百科have a text file that contains commands in this format ex:>> call <<
I want to use a regular expression to extract "call" .. how could be done?
Regex ComandStart = new Regex(">>", RegexOptions.Multiline);
Regex ComandEnd = new Regex("<<", RegexOptions.Multiline);
create the regex:
var regex = new Regex(@"ex:>>([a-z]+)<<");
then extract if match :
var match = regex.Match("ex:>>call<<");
var yourString = match.Groups[1].Value; //yourString = "call" here
If you're on Windows, you could use Notepad++ with the Regex helper plugin for testing your regex's
This expression works fine for me:
/ex:\>\>(.*)\<\</
No idea about c# specifically, sorry
精彩评论