Solved

regular expression validation

Posted on 2012-04-03
2
239 Views
Last Modified: 2012-04-09
I'm using the followin regular expression validator.  

ValidationExpression="^([a-zA-Z].*|[0-9].*)\.(((p|P)(d|D)(f|F))|((d|D)(o|O)(c|C))|((p|P)(d|D)(f|F))|((d|D)(o|O)(c|C)(x|X))|((t|T)(i|I)(f|F))|((t|T)(i|I)(f|F)(f|F))|((w|W)(p|P)(s|S))|((w|W)(p|P)(d|D))|((r|R)(t|T)(f|F)))$"

I don't understand the "=^([a-zA-Z].*|[0-9].*)\."
Can someone please help me translate this?

Thank you!
0
Comment
Question by:ocdc
[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
  • 2
2 Comments
 
LVL 35

Assisted Solution

by:Terry Woods
Terry Woods earned 500 total points
ID: 37803752
^([a-zA-Z].*|[0-9].*)\.
means:
^  match the start of the string (or line, in multiline mode)
( start a capturing group
[a-zA-Z] match any one alphabetic character
.* match any number of any characters except newline
| logical OR applying within the capturing group
[0-9] match one digit
.* match any number of any characters except newline
) end the capturing group
\. match a . character

To summarise:

It looks like you're matching filenames. That part of the pattern will match and capture the entire filename (and path, if there) up to the extension as long as it starts with a letter or number, except it won't include the . character in the captured group.
0
 
LVL 35

Accepted Solution

by:
Terry Woods earned 500 total points
ID: 37803777
Examples:

For the string:
C:\foo\rhubarb\myfile.pdf
The part of the pattern you're asking about would capture:
C:\foo\rhubarb\myfile
but would match
C:\foo\rhubarb\myfile.

For the string:
123/456/rhubarb/myfile.pdf
The part of the pattern you're asking about would capture:
123/456/rhubarb/myfile
but would match
123/456/rhubarb/myfile.

For the string:
_somedir/rhubarb/myfile.pdf
The pattern would fail to match, as it doesn't start with a number or letter.
0

Featured Post

The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

Question has a verified solution.

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

Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

688 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