Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

RegularExpressionValidator for folder names

Posted on 2010-09-02
8
Medium Priority
?
1,583 Views
Last Modified: 2013-12-17
I am using regex to validate a folder name entered in a textbox.
For that I'm using the following.

ValidationExpression="^(?!((con|prn|aux)((\.[^\\/:*?<>|]{1,3}$)|$))|[\s\.])[^\\/:*?<>|]{1,254}$" />

But I can't use " here 'cos it's breaking the string.
How can I validate it with "
0
Comment
Question by:heggies007
8 Comments
 
LVL 5

Expert Comment

by:vks_vicky
ID: 33584593
try to using [^\"]*

It will match
0
 

Author Comment

by:heggies007
ID: 33584631
Thanks for the quick response.
But I can't use that. When it see the " mark it's giving an error.
Can you please let me know how can I include the double quotes mark (") to my existing regex.
It works fine except "

Note: I am using this in a .aspx file
0
 
LVL 9

Expert Comment

by:puru1981
ID: 33584711
you can use escape character before the (")

check if it works

^(?!((con|prn|aux)((\\.[^\\/:*?<>|\"]{1,3}$)|$))|[\\s\\.])[^\\/:*?<>|]{1,254}$
0
Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

 
LVL 9

Expert Comment

by:puru1981
ID: 33584731
0
 
LVL 12

Accepted Solution

by:
Mortaza Doulaty earned 2000 total points
ID: 33584862
In case of using in aspx file, try to use &quot; instead of ".
0
 
LVL 14

Expert Comment

by:Dhanasekaran Sengodan
ID: 33584948
Check this One As well I want that these strings must be allowed c:\, c:\Program Files\, \\ahmed\,\\ahmed\Program files\,C:\program files\C booksand I have modified your Regular Expression, with this one
^(([a-zA-Z]:)|(\\{2}\w+))(\\(\w[\w ]*\w))*(\\)$ 

Open in new window

0
 

Author Comment

by:heggies007
ID: 33593745
Hi puru1981:

Thanks. But both of your solutions didn't work.
1. Won't compile
2. I was going to validate a "Folder name" not a "Folder path"


dhansmani:
Thanks.
 I was going to validate a "Folder name" not a "Folder path"

vs00saini:
Thanks for the info.

Mortaza_doulaty:
Great.. Simple solution... worked for me.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question