硒中的 C# Grep [英] C# Grep in Selenium
问题描述
我卡住了!我想知道是否有人对这个问题有想法.基本上,在这种格式的大型网页上有键"*.*.*
(没有其他文本具有这种格式)
I'm stuck! I was wondering if anyone had an idea to this problem.
Basically there are 'keys' on a huge webpage in this format *.*.*
(no other text will have that format)
我的测试套件是检查上述格式的所有键是否都在我的字典列表中(已经存在 - 但可能存在一个键可能不在字典中的情况).如果有不在列表中的键,那么它应该输出不在其中的键列表以及它在哪个页面中找到.是否有类似的方法来grep"所有包含 *.*.*
的正则表达式的文本?
My test suite is to check if all the keys in above format are in my dictionary list (which already exist - but there could be a situation where a key might not be in the diction).
If there are keys that are not in the list then it should output a list of keys that are not in it and what page it was found in.
Is there a similar way to 'grep' all the text contains this regular expression of *.*.*
?
同样,这是一个巨大的网站,因此很难遍历所有页面.但是,如果没有其他方法可以只抓取这种格式的字符串 *.*.*
Again this is a huge site so it'll be hard to traverse through all the pages. However if there is no other way is there way to grab only the string of this format *.*.*
谢谢大家,感谢您的帮助!
Thanks guys any help is appreciated!
推荐答案
Regex regex = new Regex(@"\w*\.\w*\.\w*");
MatchCollection matches = regex.Matches(searchText);
foreach (var match in matches)
{
//your code here
}
希望这会有所帮助!
这篇关于硒中的 C# Grep的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!