开发者

value extraction using regular expressions

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜