Some Useful REX Expressions

  • To locate phone numbers:
    1?\space?(?\digit\digit\digit?)?[\-\space]?\digit{3}-=\digit{4}

  • To locate social security numbers:
    \digit{3}-=\digit{2}-=\digit{4}

  • To locate text between parentheses:
    (=[^()]+)      <- without direction specification
         or
    >>(=!)+)       <- with direction specification

  • To locate paragraphs delimited by an empty line and 4 spaces:
    >>\n\n=\space\P{4}!\n\n\space\space\space\space+\F\n\n=\space{4}

  • To locate numbers in scientific notation; e.g., "-3.14 e -21":
    [+\-]?\space?>>[0-9]+\.?[0-9]*\space?e?\space?[+\-]?\space?[0-9]+


EXAMPLE

<$exprs = "[^\alpha]\P=is" "here">
<$data = "This is a test." "This was also a test." "So there.">
<rex $exprs $data>

The return values in $ret would be "is" and "here".


CAVEATS
The rex and split functions were added Oct. 14 1996. The looping syntax was added in version 2.6.938200000 19990924. At that time, both rex and split became binary compatible, i.e. varbyte data such as GIF images can be searched without truncation at nul values, and will return varbyte values. Note that $loop and $next are only set in the looping version, in syntax version 7.


SEE ALSO
sandr


Copyright © Thunderstone Software     Last updated: Oct 24 2023
Copyright © 2024 Thunderstone Software LLC. All rights reserved.