-
0 votesanswersviews
正则表达式:找到超过N个字符的分隔符
我想用逗号分隔句子,但前提是在最后一个匹配和下一个逗号之间有超过36个字符 . 所以,输入: Hello World Hello World,Hello World Hello World Hello World Hello World,Hello World,Hello World Hello World Hello World Hello World Hello World,Hello Wo... -
0 votesanswersviews
如何使用正则表达式java获取两个字符之间的数字?
I have the string as follows : SUB8&20.000, - &succes&09/12 / 18SUB12&100.000, - &failed&07/12 / 18SUB16&40.000, - &succes&09/12/18 I want to get a string "8&20.000","16&40.... -
433 votesanswersviews
如何让我的比赛在vim中不贪婪?
我有一个很大的HTML文件,有很多标记,如下所示: <p class="MsoNormal" style="margin: 0in 0in 0pt;"> <span style="font-size: small; font-family: Times New Roman;">stuff here</sp... -
303 votesanswersviews
Greedy vs. Reluctant vs. Possessive Quantifiers
我在正则表达式上找到了这个excellent tutorial,当我直观地理解"greedy","reluctant"和"possessive"量词时,我的理解似乎有一个严重的漏洞 . 具体来说,在以下示例中: Enter your regex: .*foo // greedy quantifier Enter input string... -
0 votesanswersviews
如何用sed模仿“cut -d:-f2”? (“( . *):( . *):”匹配太多字段)
为了清楚起见:我正在/ etc / passwd上测试我的代码 . 我试图用sed从文本中删除第二列(这是我老师的练习,这就是为什么我没有使用其他任何东西) . 我试过用 sed 's/\(.*\):\(.*\):\(.*\)/\2/' /etc/passwd 但它正在削减倒数第二列,可能是因为sed占据了所有字符,直到找到最后两个“:” . 如何在不指定文件中有多少的情况下剪切第二列? -
350 votesanswersviews
在sed中非贪婪(不情愿)的正则表达式匹配?
我正在尝试使用sed来清理URL行以仅提取域名.. 所以来自: http://www.suepearson.co.uk/product/174/71/3816/ 我想要: http://www.suepearson.co.uk/ (有或没有火车斜线,没关系) 我试过了: sed 's|\(http:\/\/.*?\/\).*|\1|' 和(逃避非贪婪量词) sed 's|\(http:\/\/... -
243 votesanswersviews
我如何编写一个与非贪婪相匹配的正则表达式?
我需要有关非贪婪选项的正则表达式匹配的帮助 . 匹配模式是: <img\s.*> 要匹配的文字是: <html> <img src="test"> abc <img src="a" src='a' a=b> </html> 我在http://regexpal.com上测试 此表达式匹配从 &... -
1 votesanswersviews
C正则表达式:非贪婪的比赛
我正在尝试制作一个匹配URL参数的正则表达式并提取它们 . 例如,如果我得到以下参数字符串 ?param1=someValue&param2=someOtherValue , std::regex_match 应该提取以下内容: param1 some_content param2 some_other_content 尝试不同的正则表达式模式后,我最终构建了一个与我想...