Re: Match 2 words and more

2021-11-28 Thread Thomas Markus
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? Rega

Re: Match 2 words and more

2021-11-28 Thread Peter J. Holzer
On 2021-11-28 00:27:34 +, Shaozhong SHI wrote: > It appears that regex is not robust. It does reliably what you tell it to do. I would agree that after almost 50 years of extending it, the syntax has become a bit of a mess. hp -- _ | Peter J. Holzer| Story must make more se

Re: Match 2 words and more

2021-11-28 Thread Peter J. Holzer
On 2021-11-28 00:27:34 +, Shaozhong SHI wrote: > this is supposed to find those to have 2 words and more. > > select name FROM a_table where "STREET_NAME" ~ '^[[:alpha:]+ ]+[:alpha:]+$'; I think you meant select name FROM a_table where "STREET_NAME" ~ '^[[:alpha:]+ ]+[[:alpha:]]+$'; Note

Re: Match 2 words and more

2021-11-27 Thread Ron
On 11/27/21 6:49 PM, Alvaro Herrera wrote: On 2021-Nov-28, Shaozhong SHI wrote: [snip] It appears that regex is not robust. This was my attitude when I first started to learn computer programming. /My code is perfect, i//t can't be my fault!! There must be a compiler bug!!!/ Nah. Just i

Re: Match 2 words and more

2021-11-27 Thread David G. Johnston
On Sat, Nov 27, 2021 at 5:27 PM Shaozhong SHI wrote: > 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

Re: Match 2 words and more

2021-11-27 Thread Guyren Howe
On Nov 27, 2021, at 16:27 , Shaozhong SHI wrote: > > select name FROM a_table where "STREET_NAME" ~ '^[[:alpha:]+ ]+[:alpha:]+$’; The simplest thing that does what you says is I think: select name FROM a_table where "STREET_NAME" ~ ‘^([[:alpha:]]+\s)+[[:alpha:]]+$’;

Re: Match 2 words and more

2021-11-27 Thread Alvaro Herrera
On 2021-Nov-28, Shaozhong SHI wrote: > 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. How about something like this? '^([[:<:]][[:alpha:]]+[[:>:]]( |$)){2}$' You

Re: Match 2 words and more

2021-11-27 Thread Rob Sargent
> On Nov 27, 2021, at 5:27 PM, Shaozhong SHI wrote: > >  > 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 an