Обсуждение: Regex with patterns in table field

Поиск
Список
Период
Сортировка

Regex with patterns in table field

От
"pgdb"
Дата:
Hi,
 
like to know how, if possible, for patterns
as attribute in a table to be used in a regex search with a
fixed string. The query should therefore return the rows that
have matching patterns with the single text.
 
Regards
pgdb
________________________________
Free POP3 Email from <a href="http://www.gawab.com"
target="_blank">www.gawab.com
Sign up NOW and get your account @gawab.com!!

Re: Regex with patterns in table field

От
"A. Kretschmer"
Дата:
am  13.04.2006, um 12:47:38 +0000 mailte pgdb folgendes:
>
> <HTML><DIV class=bgcolor STYLE="background-color: ;"><DIV>
> <DIV>
> <DIV>
> <DIV>Hi,</DIV>
> <DIV> </DIV>
> <DIV>like to know how, if possible, for patterns
> as attribute in a table to be used in a regex search with a
> fixed string. The query should therefore return the rows that
> have matching patterns with the single text.</DIV>

It's hard to read such text, please use plain ASCII insteed HTML.

Perhaps you are looking for something like this:

test=# select * from search;
      text
----------------
 this is a test
(1 row)

test=# select * from pattern;
  text
---------
 ^this.*
 ^foo
(2 rows)

test=# select pattern.text, search.text from pattern, search where search.text ~ pattern.text;
  text   |      text
---------+----------------
 ^this.* | this is a test
(1 row)



HTH, Andreas
--
Andreas Kretschmer    (Kontakt: siehe Header)
Heynitz:  035242/47215,      D1: 0160/7141639
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net
 ===    Schollglas Unternehmensgruppe    ===

Re: Regex with patterns in table field

От
"pgdb"
Дата:
Hi Andreas,
 
strange but I don't see html from my original email
received from the mailing list, hope this reply is ok:)
 
If I'm not wrong, the example you've provided is trying to
return matching rows from multiple patterns and texts as
inputs in the regex search.
 
The text in regular expression have to be just a single
string(with no white character) for my case. Matching should
then be done with patterns from each row, returning the row(s)
that contain matching regex pattern(s). Appreciate any advice.
Thanks.
 
Regards
pgdb
 
A. Kretschmer writes:

> am 13.04.2006, um 12:47:38 +0000 mailte pgdb
folgendes:
>>
>>


>>

>>

>>
Hi,
>>
 
>>
like to know how, if possible, for patterns
>> as attribute in a table to be used in a regex
search with a
>> fixed string. The query should therefore return
the rows that
>> have matching patterns with the single
text.
>
> It's hard to read such text, please use plain ASCII
insteed HTML.
>
> Perhaps you are looking for something like this:

>
> test=# select * from search;
> text
> ----------------
> this is a test
> (1 row)
>
> test=# select * from pattern;
> text
> ---------
> ^this.*
> ^foo
> (2 rows)
>
> test=# select pattern.text, search.text from pattern,
search where search.text ~ pattern.text;
> text | text
> ---------+----------------
> ^this.* | this is a test
> (1 row)
>
>
>
> HTH, Andreas
> --
> Andreas Kretschmer (Kontakt: siehe Header)
> Heynitz: 035242/47215, D1: 0160/7141639
> GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net
> === Schollglas Unternehmensgruppe ===
>
> ---------------------------(end of
broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faq


________________________________
Free POP3 Email from <a href="http://www.gawab.com"
target="_blank">www.gawab.com
Sign up NOW and get your account @gawab.com!!

Re: Regex with patterns in table field

От
"chris smith"
Дата:
On 4/14/06, pgdb <pgdb@gawab.com> wrote:
>
>
> Hi Andreas,
>
> strange but I don't see html from my original email received from the
> mailing list, hope this reply is ok:)
>
> If I'm not wrong, the example you've provided is trying to return matching
> rows from multiple patterns and texts as inputs in the regex search.
>
> The text in regular expression have to be just a single string(with no white
> character) for my case. Matching should then be done with patterns from each
> row, returning the row(s) that contain matching regex pattern(s). Appreciate
> any advice. Thanks.

This page might be what you're after:

http://www.postgresql.org/docs/8.1/static/functions-matching.html

--
Postgresql & php tutorials
http://www.designmagick.com/

Re: Regex with patterns in table field

От
"pgdb"
Дата:
<div class="bgcolor" style="background-color: ;"><div><div>Hi Chris,</div><div> </div><div>the query below works for me
-</div><div> </div><div>select* from TABLENAME where 'TEXT' ~ pattern;</div><div> </div><div>Thanks for
helping!</div><div> </div><div>Regards</div><div> </div><div>chrissmith writes: </div><div></div><div>> On 4/14/06,
pgdbwrote: </div><div>>> </div><div>>> </div><div>>> Hi Andreas, </div><div>>>
</div><div>>>strange but I don't see html from my original email received from the </div><div>>> mailing
list,hope this reply is ok:) </div><div>>> </div><div>>> If I'm not wrong, the example you've provided is
tryingto return matching </div><div>>> rows from multiple patterns and texts as inputs in the regex search.
</div><div>>></div><div>>> The text in regular expression have to be just a single string(with no white
</div><div>>>character) for my case. Matching should then be done with patterns from each </div><div>>>
row,returning the row(s) that contain matching regex pattern(s). Appreciate </div><div>>> any advice. Thanks.
</div><div>></div><div>> This page might be what you're after: </div><div>> </div><div>>
http://www.postgresql.org/docs/8.1/static/functions-matching.html</div><div>> </div><div>> -- </div><div>>
Postgresql& php tutorials </div><div>> http://www.designmagick.com/
</div><div></div><div></div></div></div><div>________________________________</div><div>FreePOP3 Email from <a
href="http://www.gawab.com"target="_blank">www.gawab.com</a></div><div>Sign up NOW and get your account
@gawab.com!!</div>