Control the case-sensitivity for searches
Int_Type CASE_SEARCH
If the value of CASE_SEARCH
is non-zero, text searches will be
case-sensitive, otherwise case-insensitive searches will be performed.
fsearch, ffind
bfind
Integer bfind (String str);
bfind
searches backward from the current position to the beginning
of the line for the string str
. If a match is found, the length of
str
is returned and the current point is moved to the start of the
match. If no match is found, zero is returned.
Note: This function respects the setting of the CASE_SEARCH
variable.
bsearch, ffind, bol_bsearch, re_bsearch
CASE_SEARCH
bfind_char
Integer fsearch_char (Integer ch);
This function searches backward on the current line for a character
ch
. If it is found, 1
is returned; otherwise 0
is returned.
fsearch_char, ffind_char, fsearch
CASE_SEARCH
bol_bsearch
Integer bol_bsearch (str);
bol_bsearch
searches backward from the current point until the
beginning of the buffer for the occurrences of the string str
at
the beginning of a line. If a match is found, the length of str
is
returned and the current point is moved to the start of the match. If
no match is found, zero is returned.
Note: bol_bsearch
is much faster than using re_bsearch
to perform
a search that matches the beginning of a line.
bol_fsearch, bsearch, bfind, re_bsearch
CASE_SEARCH
bol_bsearch_char
Integer bol_fsearch_char (Integer ch);
This function searches backward for a character ch
at the beginning
of a line. If it is found, 1
is returned; otherwise 0
is returned.
bol_bsearch, bol_fsearch_char, bsearch_char
CASE_SEARCH
bol_fsearch
Integer bol_fsearch (str);
bol_fsearch
searches forward from the current point until the end
of the buffer for occurrences of the string str
at the beginning of
a line. If a match is found, the length of str
is returned and the
current point is moved to the start of the match. If no match is
found, zero is returned.
Note: bol_fsearch
is much faster than using re_fsearch
to perform
a search that matches the beginning of a line.
bol_bsearch, fsearch, ffind, re_fsearch
CASE_SEARCH
bol_fsearch_char
Integer bol_fsearch_char (Integer ch);
This function searches forward for a character ch
at the beginning
of a line. If it is found, 1
is returned; otherwise 0
is returned.
bol_fsearch, bol_bsearch_char, fsearch_char
CASE_SEARCH
bsearch
Integer bsearch (String str);
The bsearch
function searches backward from the current position
for the string str
. If str
is found, this function will return
the length of str
and move the current position to the beginning of
the matched text. If a match is not found, zero will be returned and
the position will not change. It respects the value of the variable
CASE_SEARCH
.
fsearch, bol_bsearch, re_bsearch
bsearch_char
Integer fsearch_char (Integer ch);
This function searches backward for a character ch
. If it is
found, 1
is returned; otherwise 0
is returned.
fsearch_char, ffind_char, fsearch
CASE_SEARCH
ffind
Integer ffind (String s);
ffind
searches forward from the current position to the end of the
line for the string str
. If a match is found, the length of str
is returned and the current point is moved to the start of the match.
If no match is found, zero is returned.
Note: This function respects the setting of the CASE_SEARCH
variable.
To perform a search that includes multiple lines, use the fsearch
function.
fsearch, bfind, re_fsearch, bol_fsearch
ffind_char
Integer fsearch_char (Integer ch);
This function searches forwardward on the current line for a character
ch
. If it is found, 1
is returned; otherwise 0
is returned.
fsearch_char, bfind_char, fsearch
CASE_SEARCH
find_matching_delimiter
Integer find_matching_delimiter (Integer ch);
This function scans either forward or backward looking for the
delimiter that matches the character specified by ch
. The actual
direction depends upon the syntax of the character ch
. The
matching delimiter pair must be declared as such by a prior call to
define_syntax
. This function returns one of the following values:
1 Match found
0 Match not found
-1 A match was attempted from within a string.
-2 A match was attempted from within a comment
2 No information
In addition, the current point is left either at the match or is left
at the place where the routine either detected a mismatch or gave up.
In the case of a comment or a string (return values of -2 or -1), the
current point is left at the beginning of a comment.
Note: If the of ch
is zero, the character at the current point will be
used.
blink_match, create_syntax_table, define_syntax, parse_to_point
fsearch
Integer fsearch (String str);
This function may be used to search forward in buffer looking for the
string str
. If not found, this functions returns zero. However,
if found, the length of the string is returned and the current point
is moved to the to the start of the match. It respects the setting
of the variable CASE_SEARCH
. If the string that one is searching
for is known to be at the beginning of a line, the function
bol_fsearch
should be used instead.
Note: This function cannot find a match that crosses lines.
ffind, fsearch_char, bsearch, bol_fsearch, re_fsearch, looking_at
CASE_SEARCH
fsearch_char
Integer fsearch_char (Integer ch);
This function searches forward for a character ch
. If it is
found, 1
is returned; otherwise 0
is returned.
fsearch, ffind_char, bsearch_char
CASE_SEARCH
looking_at
Integer looking_at (String s);
This function returns non-zero if the characters immediately following
the current editing point match the string specified by s
. Whether
the match is case-sensitive or not depends upon the value of the
variable CASE_SEARCH
. The function returns zero if there is no match.
ffind, fsearch, re_fsearch, bfind
re_bsearch
Integer re_bsearch(String pattern);
Search backward for regular expression pattern
. This function returns
the 1 + length of the string matched. If no match is found, it returns
0.
bsearch, bol_bsearch, re_fsearch
re_fsearch
Integer re_fsearch(String pattern);
Search forward for regular expression pattern
. This function returns
the 1 + length of the string matched. If no match is found, it returns
0.
fsearch, bol_fsearch, re_bsearch
regexp_nth_match
String regexp_nth_match (Integer n);
This function returns the nth sub-expression matched by the last regular
expression search. If the parameter n
is zero, the entire match is
returned.
Note: The value returned by this function is meaningful only if the
editing point has not been moved since the match.
re_fsearch, re_bsearch
replace
Void replace(String old, String new);
This function may be used to replace all occurances of the string
old
with the string, new
, from current editing point to the end
of the buffer. The editing point is returned to the initial location.
That is, this function does not move the editing point.
replace_chars, fsearch, re_fsearch, bsearch, ffind, del
REPLACE_PRESERVE_CASE
replace_chars
Void replace_chars (Integer n, String new);
This function may be used to replace the next n
characters at the
editing position by the string new
. After the replacement, the editing
point will be moved to the end of the inserted string. The length of
the replacement string new
is returned.
fsearch, re_fsearch, bsearch, ffind, del
REPLACE_PRESERVE_CASE
replace_match
Integer replace_match(String s, Integer how);
This function replaces text previously matched with re_fsearch
or
re_bsearch
at the current editing point with string s
. If how
is
zero, s
is a specially formatted string of the form described below.
If how
is non-zero, s
is regarded as a simple string and is used
literally. If the replacement fails, this function returns zero
otherwise, it returns non-zero.
search_file
Integer search_file (String filename, String re, Integer nmax);
This function may be used to search for strings in a disk file
matching the regular expression re
. The first argument filename
specifies which file to search. The last argument nmax
specifies
how many matches to return. Each line that is matched is pushed onto
the S-Lang stack. The number of matches (limited by nmax
) is returned.
If the file contains no matches, zero is returned.