Solved

RegularExpressionValidator for folder names

Posted on 2010-09-02
8
1,570 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: 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!

 
LVL 9

Expert Comment

by:puru1981
ID: 33584731
0
 
LVL 12

Accepted Solution

by:
Mortaza Doulaty earned 500 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
 
LVL 16

Expert Comment

by:Vikram Singh Saini
ID: 33584982
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

Technology Partners: 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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

730 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