Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regular Expressions in DB2 SQL

Tags:

regex

sql

db2

(Other than using a UDF) Any REGEXP-In-SQL support for DB2 9.7 ?

like image 820
Samer Buna Avatar asked Jan 21 '11 21:01

Samer Buna


1 Answers

I'm komikoni(Keisuke Konishi).

I created the regular expression function (UDF) which does not exist in db2. The UDF using the SQL/XML(Xquery). You can easily install.

List of regular expressions provide UDF

  1. REG_MATCHES provides Coincidence existence ( Scalar )
  2. REG_REPLACE string substitution ( Scalar )
  3. REG_COUNT number of matches retrieved ( Scalar )
  4. REG_POSITION match position acquisition ( Scalar )
  5. REG_SUBSTR gets a string matching ( Scalar )
  6. REG_SUBSTR_TABLE list of matching string information ( Table )
  7. REG_TOKENIZE_TABLE list of mismatched string information (divided by a separator string) ( Table )
  8. REG_ALLTOKEN_TABLE list of mismatch string and matching string information ( Table )

Scripts can be downloaded from here. (Sorry in Japanese)

https://www.ibm.com/developerworks/jp/data/library/db2/j_d-regularexpression/

(English : Machine translation Script : The last of a Japanese page)

I look forward to your feedback and comments.

like image 84
komikoni Avatar answered Oct 06 '22 21:10

komikoni