正则表达式匹配帮助

发布于 2024-11-24 02:48:51 字数 193 浏览 2 评论 0原文

我有一个字符串..

“我是一个数字#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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我不是你的备胎 2024-12-01 02:48:51

使用此正则表达式:#[^#]*#。它将匹配 #Number##Letter#

在此处输入图像描述

Use this regex: #[^#]*#. It will match #Number# and #Letter#.

enter image description here

飘然心甜 2024-12-01 02:48:51

捕获此问题的最基本的正则表达式是:

I am a number (#[^#]+#) and I am a letter (#[^#]+#) as a test

成功的 Match 对象将包含包含您的号码的 Groups[1] 和包含您的号码的 Groups[2]信。

The most basic regex to capture this is:

I am a number (#[^#]+#) and I am a letter (#[^#]+#) as a test

A successful Match object will have Groups[1] with your number and Groups[2] with your letter.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文