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
Answertopia.com

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

  




 

 

Next: , Previous: Regexp Backslash, Up: Search


20.7 Regular Expression Example

Here is a complicated regexp—a simplified version of the regexp that Emacs uses, by default, to recognize the end of a sentence together with any whitespace that follows. We show its Lisp syntax to distinguish the spaces from the tab characters. In Lisp syntax, the string constant begins and ends with a double-quote. ‘\"’ stands for a double-quote as part of the regexp, ‘\\’ for a backslash as part of the regexp, ‘\t’ for a tab, and ‘\n’ for a newline.

     "[.?!][]\"')]*\\($\\| $\\|\t\\|  \\)[ \t\n]*"

This contains four parts in succession: a character set matching period, ‘?’, or ‘!’; a character set matching close-brackets, quotes, or parentheses, repeated zero or more times; a set of alternatives within backslash-parentheses that matches either end-of-line, a space at the end of a line, a tab, or two spaces; and a character set matching whitespace characters, repeated any number of times.

To enter the same regexp in incremental search, you would type <TAB> to enter a tab, and C-j to enter a newline. You would also type single backslashes as themselves, instead of doubling them for Lisp syntax. In commands that use ordinary minibuffer input to read a regexp, you would quote the C-j by preceding it with a C-q to prevent C-j from exiting the minibuffer.


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