Solved

RegularExpressionValidator for folder names

Posted on 2010-09-02
8
1,564 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

809 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