.NET正则表达式-在一行或多行文本块中的两个字符之间查找文本 [英] .NET Regex - Find text between two characters within a single or multiple line block of text
本文介绍了.NET正则表达式-在一行或多行文本块中的两个字符之间查找文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在使用以下正则表达式表达式:
I have been monkeying with the following regex expression:
(\b\*)\w+(\*\b)
我想做的是提取
^vitae^
来自
Nam vestibulum hendrerit justo. Quisque ^vitae^ libero magna. Curabitur pretium eros ut augue ullamcorper feugiat. Aenean blandit libero vitae nunc sodales pharetra.
但是我似乎得到的是正则表达式找到了有问题的文本并返回了所有文本而不是
But what I seem to get is that regex found the text in question and returns the all of the text in the sentence as opposed to just
^vitae^
任何帮助将不胜感激
谢谢!
推荐答案
匹配^
@"\^([^^]*)\^")
//匹配^不是^的任何内容,最后是^
//matchs ^ anything that isn't ^ and finally ^
如果有的话,它也匹配换行符
It also matches line breaks if there are any
这篇关于.NET正则表达式-在一行或多行文本块中的两个字符之间查找文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文