Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

regular expression validation

Posted on 2012-04-03
2
Medium Priority
?
242 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 1500 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 1500 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
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 …
Suggested Courses

618 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