oos-utils icon indicating copy to clipboard operation
oos-utils copied to clipboard

Add function oos_util_string.strtok

Open jeffreykemp opened this issue 8 years ago • 2 comments

Tokenize a string. Similar in functionality to strtok from C and PHP.

Useful in procedural code when the delimiter character(s) can change from token to token - i.e. not a fixed set of delimiters for the whole string.

I'll update with a simple implementation.

jeffreykemp avatar Nov 03 '17 04:11 jeffreykemp

Hi, Jeff. I have a pipelined function (in my lib package) I am using for many years. It can be used in sql or pl/sql. Here its interface function str2tbl (p_str clob, p_delimiter varchar2:= ',|;.', p_encloser varchar2:='"', p_low varchar2 := 'y' , p_split number:=0, p_char varchar2:=chr(1)) return str_arr pipelined;

It seems that it does what you are looking for, although not exactly C or PHP tokenizer. If you are interested I can submit function code.

Regards, Alex

alexys009 avatar Nov 10 '17 21:11 alexys009

Hi Alex, that's nice and might make a good addition to this package, but it's not a like-for-like replacement for strtok.

strtok is called once per token, and you can give a different delimiter (or set of delimiters) for each token.

jeffreykemp avatar Nov 11 '17 23:11 jeffreykemp