Thread: edge of word atom in PG regex engine?

edge of word atom in PG regex engine?

From
Louis-David Mitterrand
Date:
Hello,

    I am trying to match the following:

    select '4:5:67'::text ~ '4'::text as match;
     match
    -------
     t
    (1 row)

but I would like to avoid '44:5:67' matching '4' so I tried including
"word edge" regexp atoms (\b in perl, \<\> in grep and vi, etc..) but
they don't seem to be supported in Postgres:

    select '4:5:67'::text ~ '\<4\>'::text as match;
     match
    -------
     f
    (1 row)

    select '4:5:67'::text ~ '\b4\b'::text as match;
     match
    -------
     f
    (1 row)

Is there an equivalent under Postgres?

Thanks in advance,

--
Louis-David Mitterrand - ldm@apartia.org - http://www.apartia.org

Disclaimer - These opiini^H^H damn! ^H^H ^Q ^[ .... :w :q :wq :wq! ^d  X
exit X Q  ^C ^? :quitbye  CtrlAltDel  ~~q  :~q  logout  save/quit :!QUIT
^[zz ^[ZZZZZZ ^H  man vi ^@  ^L  ^[c  ^# ^E ^X ^I ^T ? help  helpquit ^D
mhelp ^C ^c help exit ?Quit ?q CtrlShftDel "Hey, what does this button d

Re: edge of word atom in PG regex engine?

From
Peter Eisentraut
Date:
Louis-David Mitterrand writes:

>     I am trying to match the following:
>
>     select '4:5:67'::text ~ '4'::text as match;
>      match
>     -------
>      t
>     (1 row)
>
> but I would like to avoid '44:5:67' matching '4' so I tried including
> "word edge" regexp atoms (\b in perl, \<\> in grep and vi, etc..) but
> they don't seem to be supported in Postgres:

select '44:5:67'::text ~ '[[:<:]]4[[:>:]]';

--
Peter Eisentraut      peter_e@gmx.net       http://yi.org/peter-e/