Click here to Skip to main content
15,883,883 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi all,

I want to validate my textbox path using regex in asp.net.

ex:
/VData/NorthCannadaBank8AB/

/VData/American-1-Bank/

/CIP_PrimeTime/


Can you please guide me .

What I have tried:

right now I am using the below regular expression , but it is not working as expected.

\{2}[\w-]+(\\{1}(([\w-][\w-\s]*[\w-]+[$$]?)|([\w-][$$]?$)))+
Posted
Updated 29-May-18 11:44am

1 solution

One of the reasons it don't match is because you match some "\" instead of "/".
This RegEx
/((\w|-|_)((\w|-|_|\s)*(\w|-|_))?/)+

matches your samples.

Just a few interesting links to help building and debugging RegEx.
Here is a link to RegEx documentation:
perlre - perldoc.perl.org[^]
Here is links to tools to help build RegEx and debug them:
.NET Regex Tester - Regex Storm[^]
Expresso Regular Expression Tool[^]
RegExr: Learn, Build, & Test RegEx[^]
This one show you the RegEx as a nice graph which is really helpful to understand what is doing a RegEx:
Debuggex: Online visual regex tester. JavaScript, Python, and PCRE.[^]
 
Share this answer
 
Comments
sai.2012 30-May-18 11:47am    
Thank you ppolymorphe.

it is working fine .

Thanks much your help.

Your are Genius Man.
Patrice T 30-May-18 12:53pm    
Just 30 years of practicing.
[no name] 2-Jun-18 6:26am    
this age deserves a 5 :-)
Patrice T 2-Jun-18 7:16am    
Thank you for the respect of my wisdom :)

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