Solved

RegularExpressionValidator for folder names

Posted on 2010-09-02
8
1,576 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
Why You Need a DevOps Toolchain

IT needs to deliver services with more agility and velocity. IT must roll out application features and innovations faster to keep up with customer demands, which is where a DevOps toolchain steps in. View the infographic to see why you need a DevOps toolchain.

 
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
 

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

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!

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…
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…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

729 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