[英]C# Regex Match from TextBox.Text?
so I'm having issues with finding regex match in textbox2.text (the text looks like a javascript file) here is my code: 所以我在textbox2.text中找到正则表达式匹配的问题(文本看起来像一个javascript文件)这里是我的代码:
string file = Regex.Match(textBox2.Text, @"rl='(.*)'", RegexOptions.IgnoreCase).Groups[0].Value;
I'm trying to find what is between rl='
& '
but I'm getting what is between + rl=' and ' the "()" don't seem to work? 我试图找到
rl='
& '
之间rl='
,但我得到的是+ rl ='和'the“()之间的东西”似乎不起作用? >.< > <
Any idea what is the issue? 不知道是什么问题?
try this regex pattern, 尝试这个正则表达式模式,
(?<=rl=').*(?=')
See Lookahead and Lookbehind Zero-Width Assertions. 请参见Lookahead和Lookbehind Zero-Width Assertions。
sample demo 示例演示
I'm trying to find what is between rl=' & '
我想找到rl ='&'之间的内容
You should use this regex then 那你应该使用这个正则表达式
@"(?<=rl\=').*?(?=')"
This regex tells the engine to match 0-n number of characters ie (.*?)
which has rl='
at the beginning of it ie (?<=rl\\=')
and end's with a '
ie(?=')
这个正则表达式告诉引擎匹配0-n个字符,即
(.*?)
,其开头是rl='
,即(?<=rl\\=')
,结尾是'
ie(?=')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.