|
Count occurences of string
[Back]
The following macro counts the occurrences of
a string in the document, which is requested via a dialog box. If the
button OK is chosen, then a literal (case insensitive) search is
performed. If Regular Exp. is chosen, then a regular expression
search is performed.
search_type = ""
search_text = string_dialog( "String to find", "OK", "Regular Exp.", "Dismiss" )
if ( $string_dialog_button == 1 )
search_type = "literal"
else if ( $string_dialog_button == 2 )
search_type = "regex"
if ( search_type != "" )
{
found = 0
pos = 0
while ( pos != -1 )
{
pos = search( search_text, pos, search_type )
if ( pos != -1)
{
pos = pos + 1
found = found + 1
}
}
dialog( "String >>" search_text "<< found [" found "] times.", "OK" )
}
[Back]
Released on Wed, 21 Nov 2001
by
C. Denat
|
|