contentsconceptssyntaxlibrariessampleserrorsindex
Full text search
Matching text up to a particular pattern  
 

Introduction

OmniMark's pattern matcher is greedy -- it consumes any character it matches. Where you want to match text up to a certain pattern but not consume that pattern the lookahead keyword is useful. The functionality of lookahead can be packaged up in a neat macro that lets you match "upto" a given pattern. The "upto" macro can be used as follows:

  find "begin" upto("end") => middle
     output middle

  find "end"
     output "fin"

This code outputs everything between, but not including, "begin" and "end". "end" is not consumed by the first rule, so it will be matched by the second rule, which will output "fin".



Sample

  macro upto (arg pat) is
     ((lookahead not (pat)) any)+
  macro-end

   
----  

Top [CONTENTS] [CONCEPTS] [SYNTAX] [LIBRARIES] [SAMPLES] [ERRORS] [INDEX]

Generated: April 21, 1999 at 2:01:43 pm
If you have any comments about this section of the documentation, send email to [email protected]

Copyright © OmniMark Technologies Corporation, 1988-1999.