swirl
Guide to OmniMark 8   OmniMark home
docs home 
IndexConceptsTasksSyntaxLibrariesLegacy LibrariesErrors
 
  Related Syntax   Related Concepts  
operator  

lookahead, lookahead not

 
 

Syntax

lookahead pattern
lookahead not pattern


Purpose

You can use lookahead to match a pattern without consuming it:

  process
     submit "Mary had a little lamb%n"
  
  find " " lookahead "little"
     output " tiny "

This program outputs "Mary had a tiny little lamb". Without lookahead, it would output "Mary had a tiny lamb".

lookahead must be applied only to part of the pattern of a find rule. If the entire rule were lookahead, no characters would be consumed and so the rule would be matched an infinite number of times. In the program above, matching the space before "little" ensures that this condition is met.

You can also match any pattern which is not followed by a certain pattern using lookahead not. This program changes the size of all the animals except the lamb.

  process
     submit "Mary had a little lamb%n"
     submit "Mary had a little horse%n"
     submit "Mary had a little pig%n"
  
  find "little " lookahead not "lamb"
     output "big "

    Related Syntax
   find
   do skip
 
Related Concepts
   Looking ahead
 
 

Top [ INDEX ] [ CONCEPTS ] [ TASKS ] [ SYNTAX ] [ LIBRARIES ] [ LEGACY LIBRARIES ] [ ERRORS ]

OmniMark 8.2.0 Documentation Generated: March 13, 2008 at 3:33:48 pm
If you have any comments about this section of the documentation, please use this form.

Copyright © Stilo International plc, 1988-2008.