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