Re: regular expression
От | Michael Fuhr |
---|---|
Тема | Re: regular expression |
Дата | |
Msg-id | 20051005055605.GA53834@winnie.fuhr.org обсуждение исходный текст |
Ответ на | regular expression (gurkan@resolution.com) |
Список | pgsql-sql |
On Mon, Oct 03, 2005 at 06:08:30PM -0400, gurkan@resolution.com 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
В списке pgsql-sql по дате отправления: