Looking for help with using regular expression match or perl language functions

Поиск
Список
Период
Сортировка
От Richard DeVenezia
Тема Looking for help with using regular expression match or perl language functions
Дата
Msg-id 059201c03e3e$b76c5ac0$0101a8c0@supermicro
обсуждение исходный текст
Ответ на Re: ok after months of freedom I'm suddenly back on the damn list aga in  (The Hermit Hacker <scrappy@hub.org>)
Ответы Re: Looking for help with using regular expression match or perl language functions  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
Hi:
I'm just getting into pgsql, but have lots of sql experience.
I've read what I can find (Momjian and docs/faqs at .org)

Consider this perl regular expression in which $1 records the part of the
text that matches my regexp:

# print first word of string when first word starts with r and ends with d
$text = "Read this Richard";
if ( $text =~ m/(^r\S*d)\b/i ) { print "first word is: '$1' \n" }

Consider this sql to create some sample data:

create table comment (text varchar(200));
insert into comment values ('Richard was here');
insert into comment values ('Read about this');
insert into comment values ('Rodeo is in town');

What would be the pgsql statement  to get a regexp match such as $1 into a
column ?

e.g., could it be like ...

select
  $1 of m/(^r\S*d)\b/i, text AS part_of_text_that_matches_regexp
from
  comments
;

If native pg does not support using regexp matches, I suppose I would want
to write a procedural language function using perl. I've yet to locate
examples of this.

I don't need help with substr and index to grab and test first words, I only
did that to simplify the example.  In reality I am using much more
convoluted and complicated regular expressions.

TIA,

Richard DeVenezia


В списке pgsql-general по дате отправления:

Предыдущее
От: Pawel Wegrzyn
Дата:
Сообщение: latest version?
Следующее
От: Peter Keller
Дата:
Сообщение: Re: Problems with genetic optimizer