On Mon, Oct 03, 2005 at 06:08:30PM -0400, [EMAIL PROTECTED] wrote: > How do I do regular expression for the problem that I am having > I have a string called desc, and say that this string in > > "TSWUU" ------ "" > "4 - DSC" ------ "4" > "6768 - THY" ------ "6768" > > basically string may or may not start with number, > I need substring of digits parts > "" > "4" > "6768"
See "Pattern Matching" in the documentation: http://www.postgresql.org/docs/8.0/interactive/functions-matching.html Example: test=> SELECT id, data FROM foo; id | data ----+------------ 1 | TSWUU 2 | 4 - DSC 3 | 6768 - THY (3 rows) test=> SELECT id, substring(data FROM '^([[:digit:]]+)') FROM foo; id | substring ----+----------- 1 | 2 | 4 3 | 6768 (3 rows) -- Michael Fuhr ---------------------------(end of broadcast)--------------------------- TIP 2: Don't 'kill -9' the postmaster