Description: Documentation

## variable CASE_SEARCH

### Synopsis

Control the case-sensitivity for searches

### Usage

Int_Type CASE_SEARCH

### Description

If the value of CASE_SEARCH is non-zero, text searches will be case-sensitive, otherwise case-insensitive searches will be performed.

### See also

fsearch , ffind

## function bfind

### Synopsis

bfind

### Usage

Integer bfind (String str);

### Description

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.

### See also

bsearch , ffind , bol_bsearch , re_bsearch

### See also

CASE_SEARCH

## function bfind_char

### Synopsis

bfind_char

### Usage

Integer fsearch_char (Integer ch);

### Description

This function searches backward on the current line for a character ch . If it is found, 1 is returned; otherwise 0 is returned.

### See also

fsearch_char , ffind_char , fsearch

### See also

CASE_SEARCH

## function bol_bsearch

### Synopsis

bol_bsearch

### Usage

Integer bol_bsearch (str);

### Description

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.

### See also

bol_fsearch , bsearch , bfind , re_bsearch

### See also

CASE_SEARCH

## function bol_bsearch_char

### Synopsis

bol_bsearch_char

### Usage

Integer bol_fsearch_char (Integer ch);

### Description

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.

### See also

bol_bsearch , bol_fsearch_char , bsearch_char

### See also

CASE_SEARCH

## function bol_fsearch

### Synopsis

bol_fsearch

### Usage

Integer bol_fsearch (str);

### Description

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.

### See also

bol_bsearch , fsearch , ffind , re_fsearch

### See also

CASE_SEARCH

## function bol_fsearch_char

### Synopsis

bol_fsearch_char

### Usage

Integer bol_fsearch_char (Integer ch);

### Description

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.

### See also

bol_fsearch , bol_bsearch_char , fsearch_char

### See also

CASE_SEARCH

## function bsearch

### Synopsis

bsearch

### Usage

Integer bsearch (String str);

### Description

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 .

### See also

fsearch , bol_bsearch , re_bsearch

## function bsearch_char

### Synopsis

bsearch_char

### Usage

Integer fsearch_char (Integer ch);

### Description

This function searches backward for a character ch . If it is found, 1 is returned; otherwise 0 is returned.

### See also

fsearch_char , ffind_char , fsearch

### See also

CASE_SEARCH

## function ffind

### Synopsis

ffind

### Usage

Integer ffind (String s);

### Description

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.

### See also

fsearch , bfind , re_fsearch , bol_fsearch

## function ffind_char

### Synopsis

ffind_char

### Usage

Integer fsearch_char (Integer ch);

### Description

This function searches forwardward on the current line for a character ch . If it is found, 1 is returned; otherwise 0 is returned.

### See also

fsearch_char , bfind_char , fsearch

### See also

CASE_SEARCH

## function find_matching_delimiter

### Synopsis

find_matching_delimiter

### Usage

Integer find_matching_delimiter (Integer ch);

### Description

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.

### See also

blink_match , create_syntax_table , define_syntax , parse_to_point

## function fsearch

### Synopsis

fsearch

### Usage

Integer fsearch (String str);

### Description

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.

### See also

ffind , fsearch_char , bsearch , bol_fsearch , re_fsearch , looking_at

### See also

CASE_SEARCH

## function fsearch_char

### Synopsis

fsearch_char

### Usage

Integer fsearch_char (Integer ch);

### Description

This function searches forward for a character ch . If it is found, 1 is returned; otherwise 0 is returned.

### See also

fsearch , ffind_char , bsearch_char

### See also

CASE_SEARCH

## function looking_at

### Synopsis

looking_at

### Usage

Integer looking_at (String s);

### Description

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.

### See also

ffind , fsearch , re_fsearch , bfind

## function re_bsearch

### Synopsis

re_bsearch

### Usage

Integer re_bsearch(String pattern);

### Description

Search backward for regular expression pattern . This function returns the 1 + length of the string matched. If no match is found, it returns 0.

### See also

bsearch , bol_bsearch , re_fsearch

## function re_fsearch

### Synopsis

re_fsearch

### Usage

Integer re_fsearch(String pattern);

### Description

Search forward for regular expression pattern . This function returns the 1 + length of the string matched. If no match is found, it returns 0.

### See also

fsearch , bol_fsearch , re_bsearch

## function regexp_nth_match

### Synopsis

regexp_nth_match

### Usage

String regexp_nth_match (Integer n);

### Description

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.

### See also

re_fsearch , re_bsearch

## function replace

### Synopsis

replace

### Usage

Void replace(String old, String new);

### Description

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.

### See also

replace_chars , fsearch , re_fsearch , bsearch , ffind , del

### See also

REPLACE_PRESERVE_CASE

## function replace_chars

### Synopsis

replace_chars

### Usage

Void replace_chars (Integer n, String new);

### Description

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.

### See also

fsearch , re_fsearch , bsearch , ffind , del

### See also

REPLACE_PRESERVE_CASE

## function replace_match

### Synopsis

replace_match

### Usage

Integer replace_match(String s, Integer how);

### Description

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.

## function search_file

### Synopsis

search_file

### Usage

Integer search_file (String filename, String re, Integer nmax);

### Description

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.