Skip to content

String.Search

boxgaming edited this page Aug 5, 2025 · 3 revisions

Executes a search for a match between a regular expression and this string, returning the index of the first match in the string, or 0 if no match was found.

Syntax

result = String.Search (s$, regex$)

Parameters

  • The s$ parameter contains the string to search.
  • The regex$ parameter contains the regular expression used to search within s$.

Example

Import String From "lib/lang/string.bas"

Dim s As String
s = "The quick brown fox jumped over the lazy dog."

Print String.Search(s, "[^\w\s']"); 'Anything not a word character, whitespace or apostrophe
Print " "; Mid$(s, String.Search(s, "[^\w\s']"))

Output

 45  .

See Also

String.Match
Javascript - String.search()

Clone this wiki locally