Search code examples
sqlregexhsqldb

SQL Regex - Select everything after '/' and split into array


I have to write a HSQLDB query that splits this string on '/'

/2225/golf drive/#305/Huntsville/AL/1243

This is where I am at

select REGEXP_SUBSTRING_ARRAY(Terms, ''/[a-zA-Z0-9]*'') as ARR from Address

This is giving me

/2225, /golf, /, /Huntsville, /AL, /1243 - (Missing "#305" and "drive" in second split)

How can I modify the regex such that it includes everything after "/" and give me this result

/2225, /golf drive, /#305, /Huntsville, /AL, /1243

Solution

  • In this case why can't you use /[a-zA-Z0-9, #]* regexp? It seems good for your goal.

    I've checked, it works here for me: https://regex101.com/r/8bJQEk/1

    PS This regexp /\/([^\/]*)/g can helps to split everything. Be careful with slashes). Example