Solved

regular expression validation

Posted on 2012-04-03
2
236 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
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

808 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