Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions

  




 

 

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.4 Regular Expression Shortcuts

Writing out regular expressions can be problematic. For example, if we want to have a regular expression that matches all digits, we have to write:

(0|1|2|3|4|5|6|7|8|9)

It would be terribly annoying to have to write such things out. So, Perl gives an incredible number of shortcuts for writing regular expressions. These are largely syntactic sugar, since we could write out regular expressions in the same way we did above. However, that is too cumbersome.

For example, for ranges of values, we can use the brackets, []'s. So, for our digit expression above, we can write [0-9]. In fact, it is even easier in perl, because \d will match that very same thing.

There are lots of these kinds of shortcuts. They are listed in the `perlre' online manual. They are listed in many places, so there is no need to list them again here.

However, as you learn about all the regular expression shortcuts, remember that they can all be reduced to the original operators we discussed above. They are simply short ways of saying things that can be built with regular characters, *, (), and |.




 
 
  Published under the terms of the GNU General Public License Design by Interspire