# 22. Virtuoso Functions Guide - regexp_parse

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_parse

returns substrings that match the regular expression in supplied string after an offset
index_vector regexp_parse (in pattern string, in target_string string, in offset integer);
Description

It applies regular expression to target_str with offset. This function returns a vector containing 2 elements for first match of the pattern and if there a sub expressions : 2 elements for each of subexpression match. The first (even numbered) element of each pair is the start index and the second (odd numbered) is the end index of the match. The regexp_parse function is more efficient than regexp_match and regexp_substr, because it doesn't allocate strings.

    	  SQL> select regexp_parse('(2[34]).*(2[35])','22232225222323', 0);
    	  callret
    	  VARCHAR
    	  _______________________________________________________________________________

    	  lvector(2,14,2,4,12,14)

    	  1 Rows. -- 10 msec.

Where: 2-14 is a range matched by whole expression, 2-4 is a range where '(2[34])' is matched , and 12-14 is a range where '(2[35])' subexpression matched.

Examples

    CREATE PROCEDURE all_tokens2 (IN pattern VARCHAR,IN str VARCHAR, IN offs INTEGER)
    {

    	DECLARE vec ANY;
    	DECLARE i INTEGER;
    	DECLARE out_str VARCHAR;

    	vec:=regexp_parse(pattern,str,offs);
    	IF ((vec IS NOT NULL) AND (length(vec)>1))
    	{
    		out_str:='';
    		i:=0;
    		WHILE ( (length(vec)/2) > i )
    		{
    			out_str:=concat(out_str,'/',
    				subseq(str,aref(vec,(i)*2),
    				aref(vec,(i)*2+1)));
    			i:=i+1;
    		};
    		RETURN concat(out_str,test_parsing(pattern,str,aref(vec,1)+1));
    	}
    	return NULL;
    };

See Also

regexp_match()

regexp_like()

regexp_instr()

regexp_replace()

regexp_substr()