正则表达式匹配的HTML标签和提取文本 [英] RegEx matching HTML tags and extracting text

查看:784
本文介绍了正则表达式匹配的HTML标签和提取文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的测试这样的字符串:

I have a string of test like this:

<customtag>hey</customtag>



我想使用正则表达式来修改customtag标记之间的文本,以便它可能看起来像这样的:

I want to use a RegEx to modify the text between the "customtag" tags so that it might look like this:

<customtag>hey, this is changed!</customtag>



我知道,我可以用一个MatchEvaluator修改的文本,但我不能确定正确的正则表达式语法使用。任何帮助将非常感激。

I know that I can use a MatchEvaluator to modify the text, but I'm unsure of the proper RegEx syntax to use. Any help would be much appreciated.

推荐答案

我不会用正则表达式无论是这一点,但如果你必须在这个表达式应该工作:(?+)
< customtag>< / customtag>

I wouldn't use regex either for this, but if you must this expression should work: <customtag>(.+?)</customtag>

这篇关于正则表达式匹配的HTML标签和提取文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆