Solved

RegularExpressionValidator for folder names

Posted on 2010-09-02
8
1,554 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
 
LVL 9

Expert Comment

by:puru1981
ID: 33584731
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

743 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now