Solved

regular expression validation

Posted on 2012-04-03
2
233 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
  • 2
2 Comments
 
LVL 35

Assisted Solution

by:Terry Woods
Terry Woods earned 500 total points
Comment Utility
^([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
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

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 …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

771 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

11 Experts available now in Live!

Get 1:1 Help Now