Click here to Skip to main content
15,886,802 members
Please Sign up or sign in to vote.
1.23/5 (3 votes)
I need a regex pattern for below words:


100$
₹100
Posted
Updated 19-Nov-13 19:55pm
v2
Comments
Ron Beyer 20-Nov-13 0:28am    
You want to find those words exactly, or that pattern (number and $ or sign then number)?
bala_1990 20-Nov-13 0:45am    
for getting numbers pattern i can find.I need pattern to find currency and $ symbols
♥…ЯҠ…♥ 20-Nov-13 0:43am    
Is it a word or currency? you need regex to validate currency right?
bala_1990 20-Nov-13 0:44am    
yes its currency and another one is $ symbol
♥…ЯҠ…♥ 20-Nov-13 0:59am    
For indian currency symbol its failing :(

1 solution

Hi Bala,

Here is the regex for dollar symbol

^([0-9]{1,3}\$?)$ (dollar optional here)

If dollar mandatory at last with single appearance then use this

^([0-9]{1,3}\$)$ or ^([0-9]{1,3}\${1})$ (dollar mandatory here)

will allow 100$, 111$, 001$, 123$.

For indian currency you can try this

^(\₹[0-9]{1,3})$ (rupee symbol is mandatory and should appear at first character)

but its not working in Rubular regex tester[^]
Since ₹ does'nt have any description for it, its working in here.So I hope it would work for you also.

Hope this helps you a bit.

Regards,
RK
 
Share this answer
 
v5
Comments
bala_1990 20-Nov-13 2:03am    
Both pattern is finding only numeric characters.Not finding $(dollar) with Number.Any way thanks for the help!
♥…ЯҠ…♥ 20-Nov-13 2:22am    
see my updated answer to dollar(mandatory) requirement
bala_1990 20-Nov-13 4:30am    
rupee pattern is working correctly,but dollar is not working!
♥…ЯҠ…♥ 20-Nov-13 4:53am    
updated my solution check it now

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