Posted by: peteinman | December 2, 2009

Oracle Service Bus – fn:tokenize

If you have a string, such as a file name which looks like

“FileName.txt”

How do you get the filename without the extension?

Use the following XQuery function

fn:tokenize(‘FileName.txt’, ‘\.’)[1]

That function will get the first element of the tokenized array.

Note that the escaped “.” is important otherwise you won’t get anything returned.

fn:tokenize(‘FileName.txt’, ‘\.’)[last()]

will return the last element, in this case “.txt” and you can also do last()-1 to get the previous element.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: