# 22. Virtuoso Functions Guide - regexp_match

Chapter Contents | Prev | Next
Keyword Search:
www.openlinksw.com
docs.openlinksw.com
Book Home
Contents
Preface
Virtuoso Functions Guide
Administration
Aggregate Functions
Array Manipulation
BPEL APIs
Backup
Compression
Cursor
Date & Time Manipulation
Debug
Dictionary Manipulation
Encoding & Decoding
File Manipulation
Free Text
Hashing / Cryptographic
LDAP
Locale
Mail
Miscellaneous
Number
Remote SQL Data Source
Replication
SOAP
SQL
String
ascii
atoi
blob_to_string
blob_to_string_outpu...
chr
initcap
isblob
isstring
lcase
left
length
locate
ltrim
make_string
regexp_instr
regexp_like
regexp_match
regexp_parse
regexp_replace
regexp_substr
repeat
replace
right
rtrim
search_excerpt
serialize
space
split_and_decode
sprintf
strcasestr
strchr
string_output
string_output_flush
string_output_gz_com...
string_output_string
string_to_file
strrchr
strstr
subseq
substring
tmp_file_name
trim
ucase
upper
Transaction
Type Mapping
UDDI
User Defined Types & The CLR
Virtuoso Java PL API
Virtuoso Server Extension Interface (VSEI)
Web Server & Internet
XML
XPATH & XQUERY
Functions Index

## regexp_match

returns a substring matching the regular expression to the supplied string
varchar regexp_match (in pattern any, inout str any, [in change_the_str integer]);
Description

The regexp_match function returns a copy of substring of string str which matches the regular expression pattern.

Previous behavior of this function would cut the first characters of str until the end of regular expression matched substring. In this way str could be passed to this function again to find the next occurrence of substring that matches the regular expression. By default this behavior is not adopted by this function, but can be enabled for pre 3.2 compatibility by supplying the optional third parameter.

If either the pattern or str parameter contain wide characters this function will operate in wide mode, first converting any narrow characters to wide and returning a wide character response. Otherwise this function operates in narrow mode by default.

Parameters
pattern – The regular expression to match.
str – The string to be searched. In compatibility mode (change_the_str =1) this string in modified, removing the matched substring.
change_the_str – This new parameter allows this function to operate in pre 3.2 compatibility mode which modified the original string. By default this parameter is set to "0" so that the original string is never altered.
Returns

This function returns the a substring matching the regular expression.

Examples
Examples

    CREATE PROCEDURE all_tokens(IN pattern VARCHAR, IN str VARCHAR)
    {
    	DECLARE wrd VARCHAR;
    	DECLARE ans VARCHAR;
    	DECLARE str_i VARCHAR;

    	ans:='';
    	str_i := str;
    	wrd := regexp_match(pattern,str_i);
    	WHILE (wrd IS NOT NULL)
    	{
    		ans := concat(ans,',',wrd);
    		wrd := regexp_match(pattern, str_i, 1);
    	};
    	RETURN ans;
    };

See Also

regexp_parse()

regexp_like()

regexp_instr()

regexp_replace()

regexp_substr()