Re: Match 2 words and more - Mailing list pgsql-general

From Thomas Markus
Subject Re: Match 2 words and more
Date
Msg-id f0712672-3a2a-11bf-e94b-801ebfb2ccf0@proventis.net
Whole thread Raw
In response to Match 2 words and more  (Shaozhong SHI <shishaozhong@gmail.com>)
List pgsql-general

Am 28.11.21 um 01:27 schrieb Shaozhong SHI:
> this is supposed to find those to have 2 words and more.
>
> select name FROM a_table where "STREET_NAME" ~ '^[[:alpha:]+ 
> ]+[:alpha:]+$';
>
> But, it finds only one word as well.
>
> It appears that regex is not robust.
>
> Can anyone shed light on this?
>
> Regards,
>
> David
Hi,

It's robust, but syntax is sometimes weired

for words I would use something like (contains numbers too)
"STREET_NAME" ~ '(\w+\s+)+\w+';

or alpha only
"STREET_NAME" ~ '([[:alpha:]]+\s+)+[[:alpha:]]+'

regards
Thomas



pgsql-general by date:

Previous
From: Gavin Flower
Date:
Subject: Re: [EXTERNAL] Re: Inserts and bad performance
Next
From: Wicher
Date:
Subject: DDL tools for working with views in dependency order?