Finding words strictly starting with $, Regex C#
Posted
by Anirudh Goel
on Stack Overflow
See other posts from Stack Overflow
or by Anirudh Goel
Published on 2009-03-05T15:51:07Z
Indexed on
2010/05/13
20:14 UTC
Read the original article
Hit count: 320
I need to find all matches of word which strictly begins with "$" and contains only digits. So I wrote
[$]\d+
which gave me 4 matches for
$10 $10 $20a a$20
so I thought of using word boundaries using \b:
[$]\d+\b
But it again matched
a$20 for me.
I tried
\b[$]\d+\b
but I failed.
I'm looking for saying, ACCEPT ONLY IF THE WORD STARTS WITH $ and is followed by DIGITS. How do I tell IT STARTS WITH $, because I think \b is making it assume word boundaries which means surrounded inside alphanumeric characters.
What is the solution?
© Stack Overflow or respective owner