开发者

Regular Expression Match Help

开发者 https://www.devze.com 2023-03-20 09:06 出处:网络
I have a string.. \"I am a number #Number# and I am a letter #Letter# as a test\" I am trying to use a Re开发者_StackOverflowgex.Matches to grab the string #Number# and #Letter# out of the string..

I have a string..

"I am a number #Number# and I am a letter #Letter# as a test"

I am trying to use a Re开发者_StackOverflowgex.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


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

Regular Expression Match Help


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消