Regular Expression Match Help
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#
.
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.
精彩评论