# 22. Virtuoso Functions Guide - subseq

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

## subseq

returns substring of a string or sub-vector of a vector
subseq ( str string or vector , from integer, [to integer or NULL]);
Description

subseq returns a copy of subsequence of string or vector str using zero-based indices from (inclusive) and to (exclusive) to delimit the substring or the vector extracted.

If to is omitted or is NULL, then it equals by default to the length of str, i.e. everything from from to the end of str is returned.

If to and from are equal, an empty string ''(empty vector) is returned.

If from is greater than to or length of str an error is signalled.

If str is NULL then NULL is returned.

    subseq('AbracadabrA',0,4) -> 'Abra'
    subseq('AbracadabrA',4,8) -> 'cada'
    subseq('AbracadabrA',7)    -> 'abrA'
    subseq(string,0,strchr(string,'/'))
    subseq(vector (1, 2, 3), 2) -> vector (3)
    subseq(vector (1, 2, 3), 0, 2) -> vector (1, 2)

The last one with string argument returns a copy of the string cut from the first slash, leaving it and everything following out, and in the case where there are no slashes present, returns a copy of the whole string.