正则表达式匹配帮助
我有一个字符串..
“我是一个数字#Number#,我是一个字母#Letter#作为测试”
我试图使用Regex.Matches从字符串中获取字符串#Number#和#Letter# ..
我尝试了一堆不同的正则表达式,但没有任何运气。
知道使用哪种正则表达式模式来提取 # 之间的单词,但在两侧都包含 #
I have a string..
"I am a number #Number# and I am a letter #Letter# as a test"
I am trying to use a Regex.Matches to grab the string #Number# and #Letter# out of the string..
Ive tried a bunch of different regular expressions without any luck
Any idea what kind of regular expression pattern to use to pull out the words between the # but include the # on both sides
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用此正则表达式:
#[^#]*#
。它将匹配#Number#
和#Letter#
。Use this regex:
#[^#]*#
. It will match#Number#
and#Letter#
.捕获此问题的最基本的正则表达式是:
成功的
Match
对象将包含包含您的号码的Groups[1]
和包含您的号码的Groups[2]
信。The most basic regex to capture this is:
A successful
Match
object will haveGroups[1]
with your number andGroups[2]
with your letter.