|
|
| About site: Programming/Languages/Regular Expressions - Common Applications of Regular Expressions |
Return to Computers also Computers |
| About site: http://www.4guysfromrolla.com/webtech/120400-1.shtml |
Title: Programming/Languages/Regular Expressions - Common Applications of Regular Expressions This article by Richard Lowe demonstrates four powerful and practical applications of regular expressions. |
|
|
|
|
Netsong Offers web site building, hosting solutions, webmaster courses, website administration, consulting, and support.
| Password_Protection_Gates_-_4AF Protect the sentitive information on web site with a password gate. Protects entire site or only a few pages with multiple log-ins and access levels.
| StopIE A former Anti-Internet Explorer site. Described problems and alternatives.
| eLearning_Corner Flash based, scorm-compatible online computer security awareness courses to improve corporate IT security by modifying employee behaviors.
| Resource_Tuner Advanced visual resource editor, quickly browse, edit and modify the resources contained within 32 bit Windows executable files. Support is provided for nearly every type of binary resource imaginable
| StarTech_com Manufacturer of computer components and cables. Online ordering available. Offices in US, Canada and UK.
|
|
| Alexa statistic for http://www.4guysfromrolla.com/webtech/120400-1.shtml |
Please visit: http://www.4guysfromrolla.com/webtech/120400-1.shtml
|
| Related sites for http://www.4guysfromrolla.com/webtech/120400-1.shtml |
| TracePlus_Web_Detective_(eBusiness_Edition) TracePlus/Web Detective (eBusiness Edition) is a performance analysis and diagnostic tool specifically designed for Web development. Analyze the HTTP and HTTPS protocols used by an application and vie | | Pam\'s_Skins Personal Icq, Winamp and Yahoo skins. | | Ben_Forta Adobe ColdFusion evangelist's personal weblog. | | ItzaZoo_Software Record keeping software for small or home-based businesses. | | Joysticks_and_Related_Input_Devices Information on joysticks and related devices for SGI workstations. | | Educational_software A range of software tools for use in the classroom. | | ExploreCommerce Design custom web-based and e-mail surveys for market research and e-marketing. Generates HTML for web-based survey for you to place on your Web site. | | Centum Interpreted language intended to make it easy to express algorithms. Merges functional, object-oriented, and imperative programming styles, and adds some unique traits. | | SDLMappy Library that uses 2D tiles based maps created by Mappy. It allows layer transparency, animations, and the creation of up to eight different layers. | | My_Mac_Online Free electronic publication available for reading either online, or in two downloadable formats for offline reading: DOCMaker and Adobe Acrobat PDF. | | Responsive_Time_Logger Shareware time and billing tool for consultants, lawyers and engineers. Runs on Palm OS. | | NET-SNMP_Project Open source SNMP implementation features news, frequently asked questions, bugs list, patches available, documentation and tutorial, and mailing lists. (C, Perl) [Windows] | | OpenAFS Coordination and distribution of OpenAFS, an opensource implementation of the Andrew File System, including client and server software. | | Acceptable_Use_Policy Defines acceptable use of IT equipment and computing services, and the appropriate employee security measures to protect the organization's corporate resources and proprietary information. [MS Word] | | 1Expired_com_-_Search_And_Monitor_Expired_Domain_Names_Today_ Offers expired domain name monitoring. | | RFC_0298 Network Host Status. E. Westheimer. February 1972. | | SharkFriends_Postcards Ecards featuring marine animals. Customizable with music and colors. | | osCommerce_Community_Support_Forums Official community support forums for the osCommerce project. | | Real_Business_Solutions Offer the Payroll Mate software for accountants and small to medium-size businesses. | | Web_Dreamz Offers design and graphics services. |
|
This is websites2007.org cache of m/ as retrieved on 2008.09.07 websites2007.org's cache is the snapshot that we took of the page as we crawled the web. The page may have changed since that time.
|
4GuysFromRolla.com - Common Applications of Regular Expressions
When you think ASP, think...
Recent Articles
All Articles
ASP.NET Articles [1.x] [2.0]
ASPFAQs.com
Message Board
Related Web Technologies
User Tips!
Coding Tips
Search
Sections:
Book Reviews
Sample Chapters
Commonly Asked Message Board Questions
Headlines from ASPWire.com
JavaScript Tutorials
MSDN Communities Hub
Official Docs
Security
Stump the SQL Guru!
Web Hosts
XML Info
Information:
Advertise
Feedback
Author an Article
Technology Jobs
IT
Developer
Internet News
Small Business
Personal Technology
International
Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers
Senior Application DBA - SQL ServerProfessional Technical ResourcesUS-OR-Lake Oswego
Post A Job | Post A Resume
Published: Monday, December 04, 2000
Common Applications of Regular Expressions
By Richard Lowe
Regular Expressions (for those not yet acquainted with them) provide a way of matching patterns of strings
that may be simple or extremely complicated and they do it in a very efficient manner. For an introduction to
regular expressions in ASP be sure to read: An Introduction to Regular
Expressions in VBScript. (There are also a number of other great beginner-level articles available
at the 4Guys Regular Expression Article Index... be sure that
you have a fairly good understanding of regular expressions before deciding to tackle this article.)
- continued -
Once you know the syntax of regular expressions and perhaps have even written one or two for practice, you may
be inclined to ask "well great, but what are these things really good for in the real world?" This
article presents a sample of real-world problems facing ASP programmers every day and some highly effective
uses of Regular Expressions in solving those problems!
First, it should be noted that the regular expressions examples in this article were written under version
5.5 of the Microsoft's scripting engines. Regular Expression support has increased steadily in the last few
versions of Microsoft's VBScript and JScript and therefore some scripts may not work in previous versions.
To download the latest version of the scripting engines, visit http://msdn.microsoft.com/scripting/.
To determine what version of the scripting engines you're currently using, be sure to read:
Determining the Server-Side Scripting Language and Version!
Common Challenges
Here's a list of some of the common challenges that this article will look at and solve with regular
expressions:
Validating email and/or password formats on the server side
Extracting specific sections from an HTML page (perhaps one retrieved with XMLHttp)
Parsing text data files into sections for import into a database
Replacing values in text to clean, reformat, or change content
Validating Password Formats
Our first task of validation demonstrates a primary function of regular expressions: abstracting strings of
varying levels of complexity. What this means is that regular expressions give you, the programmer, a way to
describe a string in general terms, terms which require minimum code, but handle every case your
application will encounter. For example: A non-technical person might describe a password's minimum
requirements to you like this: "The password's first character must be a letter, it must contain at least 4
characters and no more than 15 characters and no characters other than letters, numbers and the underscore may
be used".
Now you, as the developer, have to translate that natural language expression into something the
processing ASP page can understand and use to reject invalid password choices. The regular expression that
matches the above requirement looks like this:
^[a-zA-Z]\w{3,14}$
You could implement it in a reusable way in a function in your application like this:
Function ValidatePassword(strPassword)
Dim re
Set re = new RegExp
re.IgnoreCase = false
re.global = false
re.Pattern = "^[a-zA-Z]\w{3,14}$"
ValidatePassword = re.Test(strPassword)
End Function
Here is our original definition with the relevant parts of the regular expression shown alongside (in parenthesis):
"The password's first character must be a letter (^[a-zA-Z] the carrot (^) means the
beginning of the string and the square brackets tell the regexp to match one character from any
of the group of characters inside), it must contain at least 4 characters and no more than 15 characters
({3,14}) and no characters other than letters, numbers and the underscore may be used
(\w)"
Several notes: the {3,14} indicates that at least 3 but no more than 14 of the preceding pattern
should be matched, (4 to 15 when you add the first character). It's a picky syntax inside the curly braces,
not allowing you to place a space on either side of the comma. If you do, it will silently change the meaning
of your regular expression and frustrate you when it doesn't work. Also, I didn't mentioned the $
character at the end of the regular expression - this character anchors our regular expression to the end of
the string, and it is necessary to ensure no further characters are placed after a valid password entry.
(For a more formal listing of special characters in regular expressions (such as the ^ and
$, be sure to check out this article:
Microsoft Beefs Up VBScript with
Regular Expressions!)
Similar to validating password formats is the common problem of validating email addresses, for which there
are already a wealth of documented methods of validating email addresses(including regular expression checks).
For a plethora of techniques, be sure to check out the many articles at the
Email Address Validation Article Index.
A RegExp to match email addresses might be implemented like this, displaying True or False for a valid
email address:
<%
Dim re
Set re = new RegExp
re.pattern = "^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$"
Response.Write re.Test("chadich@yahoo.com")
%>
There are many regular expressions for validating all sorts of inputs. Check out RegExLib.com
for a searchable database of common regular expression patterns!
In Part 2 we'll look at the next Regular Expression topic:
extracting specific sections from an HTML page!
Read Part 2!
Windows Internet Technology |
ASP.NET
[1.x]
[2.0] |
ASPMessageboard.com |
ASPFAQs.com |
Advertise |
Feedback |
Author an Article
var site_name = location.hostname;
if ( site_name.indexOf("www.") != 0 ) {
site_name = "www."+site_name ;
}
document.write("
       
Search:
Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia Jupitermedia Corporate Info
document.write(' Copyright ');
var now = new Date();
document.write( + now.getFullYear());
document.write(' Jupitermedia Corporation All Rights Reserved.');
Copyright 2008 Jupitermedia Corporation All Rights Reserved.
Legal
Notices, Licensing,
Reprints,
& Permissions,
Privacy
Policy.
Advertise | Newsletters
| Tech
Jobs | Shopping | E-mail
Offers
Solutions
Whitepapers and eBooks
Adobe Acrobat Connect Pro: Web Conferencing and eLearning Whitepapers
Microsoft Article: Will Hyper-V Make VMware This Decade's Netscape?
Avaya Article: Avaya AE Services Provide Rapid Telephony Integration with Facebook
Intel Go Parallel Article: Getting Started with TBB on Windows
Microsoft Article: 7.0, Microsoft's Lucky Version?
Intel Go Parallel Article: Intel Threading Tools and OpenMP
HP eBook: Storage Networking , Part 1
Avaya Article: Speech Sandbox: Application Simulation in Avaya Dialog Designer
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
HP Video: StorageWorks EVA4400 and Oracle
HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
30-Day Trial: SPAMfighter Exchange Module
Red Gate Download: SQL Toolbelt and free High-Performance SQL Code eBook
Iron Speed Designer Application Generator
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
Featured Algorithm: Intel Threading Building Blocks - parallel_reduce
Silverlight 2 App and Walkthrough: Leverage Silverlight 2 with SQL Server and XML
HP Demo: StorageWorks EVA4400
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES
|
|
| |
This | article | by | Richard | Lowe | demonstrates | four | powerful | and | practical | applications | of | regular | expressions. |
|
http://www.4guysfromrolla.com/webtech/120400-1.shtml
Common Applications of Regular Expressions 2008 September
dvd rental
dvd
This article by Richard Lowe demonstrates four powerful and practical applications of regular expressions.
Rules
|
© 2008 Internet Explorer 5+ or Netscape 6+
|
|
Recommended Sites: 1.
Arts -
Business -
Computers -
Games -
Health -
Home -
Kids and Teens -
News -
Recreation -
Reference -
Regional -
Science -
Shopping -
Society -
Sports -
World
Miss Gallery
- Top Anime Hentai
- DVD rental by mail
- Car Finance - Free Myspace Layouts - Mortgage - Remortgage - Internet Advertising
|