DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Lexical analysis with lex

Regular expressions

You specify the patterns you are interested in with a notation called a regular expression. A regular expression is formed by stringing together characters with or without operators. The simplest regular expressions are strings of text characters with no operators at all:

   apple
   orange
   pluto

These three regular expressions match any occurrences of those character strings in an input text. If you want to have the scanner remove every occurrence of orange from the input text, you could specify the rule

   orange  ;
Because you specified a null action on the right with the semicolon, the scanner does nothing but print out the original input text with every occurrence of this regular expression removed, that is, without any occurrence of the string orange at all.
Next topic: Operators
Previous topic: The fundamentals of lex rules

© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 27 April 2004