Contents of Article


Delimited Search Strings

Example Searches


Introduction


Like Picture Strings,  Delimiter strings  provide another alternative to perform pattern-matching which can be simpler to use than Regular expressions. This literal type allows you to search for strings of varying length which are delimited by some identifiable characters.  For example strings within brackets or parenthesis. Or quoted strings.



Delimited Search Strings


Delimited search strings are specified using a D type literal.  e.g. D"(|)"   


A delimited literal consists of 3 parts: A Prefix, a vertical divider bar and a Suffix.   It requests a search for a string which is preceded by the Prefix and followed by the Suffix.   The searched for string between the Prefix and Suffix can be from 0 to any length.


Example:  FIND D"(|)"  requests a search for any string surrounded by parenthesis, like (ABC) or (123.45)


The search, when found, selects from the Prefix through the Suffix, inclusive, not just the data in-between.


What if a |  or \ character is in my Prefix or Suffix


If this occurs, simply precede the | or \ with a \ (Backslash) character. The \ acts as an 'escape' character. The escape character says "the next character is NOT 'special'". For example, if you wanted to find strings preceded by <| and followed by |>, it would be:


D"<\||\|>"

  ___|___

   | | |

   | | +- The Suffix     \|>

   | +--- The separator  |

   +----- The Prefix     <\|


This also means if you want a \ character, it must be doubled to \\.


Missing Prefix or Suffix


It is possible to specify only one of the Prefix or Suffix strings.   e.g D"ABC|"   or   D"|DEF"


When this is done, please understand the handling of such requests carefully.


Missing Prefix


When the suffix is found, the returned string will be (inclusive) from the start scan location up to and including the Suffix. Please remember that when doing RFIND, the start scan is 1 character to the right of the previous found location, NOT  1 character to the right of the found string.


Missing Suffix


This depends on whether the Prefix string occurs again - further right in the line.

    1. If it does, the returned string will be from the start of the found Prefix to the character prior to the next occurrence of the Prefix.
    2. If it does not, the returned string will be from the start of the found Prefix to the end of the line. 



The above description is specified in terms of normal forward searches.  If doing reverse searches (for example FIND .... LAST and then RFIND) the comments for Suffix and Prefix are reversed as the scan is working in the other direction.


WARNING:  If you are going to use either of the missing Prefix / Suffix modes, experiment first to make sure you understand what is happening.  The results are not intuitively obvious.


Example Searches


This example finds quoted strings'


Command > FIND D'"|"'

****** ----+----1----+----2----+----3----+----4----+

000001 Say "Hello" to everyone in

000002 apartments (2) and (4)

000003 Phone: 1-212-555-1234


Result:

****** ----+----1----+----2----+----3----+----4----+

000001 Say "Hello" to everyone in

000002 apartments (2) and (4)

000003 Phone: 1-212-555-1234


Note the use of single quotes to create the literal containing double quotes.


This next example is similar, but shows the use of  column range operands


Command > F D'(|)' ALL 15 30

****** ----+----1----+----2----+----3----+----4----+

000001 Say "Hello" to everyone in

000002 apartments (2) and (4)

000003 Phone: 1-212-555-1234


Result:

****** ----+----1----+----2----+----3----+----4----+

000001 Say "Hello" to everyone in

000002 apartments (2) and (4)

000003 Phone: 1-212-555-1234


Note that the string (2) was not found because it was outside the specified column bounds of 15-30.


This next example shows the use of a missing Suffix in the D literal


Command > F D'(|' 

****** ----+----1----+----2----+----3----+----4----+

000001 Say "Hello" to everyone in

000002 apartments (2) and (4)

000003 Phone: 1-212-555-1234


Result:

****** ----+----1----+----2----+----3----+----4----+

000001 Say "Hello" to everyone in

000002 apartments (2) and (4)

000003 Phone: 1-212-555-1234


Note that because the Prefix string ( occurred again further right, the found string stops at the preceding character.


If an RFIND was issued at this point


Result:

****** ----+----1----+----2----+----3----+----4----+

000001 Say "Hello" to everyone in

000002 apartments (2) and (4)

000003 Phone: 1-212-555-1234


The RFIND now selects from the ( to the end of line since no further occurrences of ( are found.


Created with the Personal Edition of HelpNDoc: Keep Your PDFs Safe from Unauthorized Access with These Security Measures