正则表达式 - 冒号之间的文本 [英] Regular expression - Text between colons

查看:149
本文介绍了正则表达式 - 冒号之间的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个这样的架构

<h1>
5/2009
<br/>
Question: This is the question
</h1>

我喜欢在 <br/> 之后获取第一部分或总是在冒号 之前的字符串:

I like to get the first part after the <br/> or always the string before the colon :

--> 解决方案应该是问题"

--> Solution should be "Question"

注意:这个词会改变 - 有时是问题,有时可能是大问题......

Attention: This words change - Sometimes its question, othertime may be big question ....

我尝试使用

(.{0,50}):(.{0,50}) 但这会返回很多(也是日期)

I tried with <h1>(.{0,50}):(.{0,50}) but this returns to much (also the date)

我没有接受过正则表达式的培训,有人可以帮我吗?

I'm not trained with regex, can anyone help me with this?

非常感谢.

推荐答案

试试这个:

<br/>([^:]+):

这篇关于正则表达式 - 冒号之间的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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