Jump to content
Larry Ullman's Book Forums

Recommended Posts

Regular expressions?

 

They are incredibly useful, but can be confusing to start with. You can use them in .htaccess files to make pretty urls and more importantly help validate types of input of varying types of complexities. Check out regexlib in Google, you'll where they're used. Things like validating telephone numbers, post codes and a lot more.

Link to comment
Share on other sites

Without exaggeration, regular expressions are one of the most important and useful inventions in the history of computers and programming. Period. So much of what's done by software is searching for things, whether it's text within strings or files within a directory. Without regular expressions you can only search for specific, literal things. For example, it'd take two searches to find every file that's a .jpg or .jpeg. Or four, if you factor in case sensitivity. With regular expressions, that's one search. Matching email addresses, phone numbers, names, postal codes, URLs, other numbers, and so forth, all requires regular expressions. Which is to say that a ton of security is added by using regex.

 

Yes, regular expressions is all about matching patterns, but that's kind of like saying that airplanes are just about allowing you to travel through the air. Compared to the alternatives, it's a pretty big difference.

Link to comment
Share on other sites

 Share

×
×
  • Create New...