Click here to Skip to main content
15,892,768 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I am fetching words which starts with $ sign from a sentence. for this I have written as
Regex.Matches(body, "(\\$\\w+) ").

But my current requirement is to fetch words which starts with two consecutive $ sign.

for an example:
sentence:-my name is $$shibashish and age is $$twenty.

result should be : shibashish and twenty.

please help me it's urgent.

Thanks in advance.
Posted
Updated 19-Aug-14 20:53pm
v2
Comments
Raul Iloc 20-Aug-14 7:44am    
Did you try like I suggested in my solution (the 3rd solution)?

Have you tried using this
C#
Regex.Matches(body, "(\\$$\\w+) ");
 
Share this answer
 
Comments
[no name] 20-Aug-14 2:49am    
Thanks Mayank for replying but this is not the correct one.
Kumarbs 20-Aug-14 2:49am    
It won't work buddy.
Regex.Matches(body, "(\\$\\$\\w+) ");
 
Share this answer
 
Comments
Raul Iloc 20-Aug-14 3:16am    
Your regex expression is not quit right, because it matches also the words that contain the "$$" inside or at the end of the string like the next examples: "aaa$$bbb", "aaa$$"!
The solution is:
C#
if(Regex.Matches(body, "^\\$\\$\\w+"))
{
    return body.Substring(2);
}


PS: You could test your regex expressions on the next site: http://regexpal.com/[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900