Xbasic

COUNT_TEXTBLOCKS Function

Syntax

Count as N = count_textblocks(C string ,C start_string ,C end_string [,L case_sensitive [,L regex_safe ]])

Arguments

stringCharacter

The string to examine for the find text.

start_stringCharacter

The beginning characters of the variable length text.

end_stringCharacter

The ending characters of the variable length text.

case_sensitiveLogical

Default = .F.; .T. = Case sensitive, .F. = Case insensitive

regex_safeLogical

Default = .F. The "unsafe" characters are ., |, *, ?, +, (, ), {, }, , , ^, $ and \. If your Start_Find_Text and End_Find_Text do not contain any of these characters, you should set Regex_Safe to true to maximize performance.

.T. = Improves performance by declaring that the start and end tags are already regular expression safe and COUNT_TEXTBLOCKS() does not need to escape special characters.

.F. = Unsafe characters are replaced. This decreases performance on a large string.

Returns

CountNumeric

The number of instances of the find text in Search_in_Text.

Description

Counts the number of occurrences of a sub-string starting with 'start_string' and ending with 'end_string'.

Discussion

The COUNT_TEXTBLOCKS() function returns the number of instances of the variable length text found in string.

Example

txt = <<%txt%
this is line one

this is line 2

this is line 3

%txt%
st = "TH"
en = "NE"
? count_textblocks(txt, st, en, .t.)
= 0
? count_textblocks(txt, st, en, .f.)
= 3

See Also