RegexSearch$() function - MapBasic - 2023

MapInfo MapBasic Reference

Product type
Software
Portfolio
Locate
Product family
MapInfo
Product
MapInfo > MapBasic
Version
2023
Language
English
Product name
MapBasic
Title
MapInfo MapBasic Reference
First publish date
1985
Last updated
2023-09-12
Published on
2023-09-12T16:32:32.686312

Purpose

This function gets the index of the first sub-string matching the given RegEx pattern with the input string. This function returns a non-negative value if the input string contains a sub-string matching the RegEx pattern. Otherwise, this function returns -1. You can call this function from the MapBasic window in MapInfo Pro.

Syntax

RegExSearch$(input_string, expression_string [, case_insensitive ] )

input_string (String): A string with the target sequence (the subject) against which the RegEx expression is matched.

expression_string (String) : The RegEx pattern to match the string to.

case_insensitive (Logical) : Character matching should be performed without regard to case.(This parameter is Optional) (default value is TRUE)

.

Return Value

Integer

Description

Use the RegexSearch$() function to

get the index of the first substring matching given RegEx pattern with the input string. This function returns a non-negative value if the input string contains a substring matching the RegEx pattern. Otherwise, this function returns -1.

case_insensitive is optional and defaults to TRUE.

Note: This function uses ECMAScript grammar for RegEx match. https://www.cplusplus.com/reference/RegEx/ECMAScript/
Note: Positive/negative lookbehind regex expression are not supported.

Examples

Print RegExSearch$("xxxabc123xyz","abc.*xyz")
//returns 4
Print RegExSearch$("abc123123", "123$")
//returns 7
Print RegExSearch$("abc123123", "123")
//returns 4
Print RegExSearch$("abc123123", "2123")
//returns -1