PL/TCL regex string matching 
Author Message
 PL/TCL regex string matching

Hi,
I'm trying to write a TCL function which uses regex string matching.
    spi_exec "SELECT count(s.id)  as res FROM services s
                    WHERE
                s.name=''email account ([0-9+])MB''";

I'd like to match any service with name starting "email account " and quota
at the end.
I was trying to use ([0-9+]), (1,2) and some others that I've found in TCL
guides.
Is it possible to use regex in PL/TCL and can You show me with the exmaple
how?

tia
mazek

Marcin Mazurek

--  
Kierownik Dzia3u Systemowego
MULTINET SA o/Poznan
http://www.***.com/



Sat, 10 May 2003 01:19:01 GMT
 PL/TCL regex string matching


Quote:
> Hi,
> I'm trying to write a TCL function which uses regex string matching.
>     spi_exec "SELECT count(s.id)  as res FROM services s
>                     WHERE
>                 s.name=''email account ([0-9+])MB''";

> I'd like to match any service with name starting "email account " and quota
> at the end.
> I was trying to use ([0-9+]), (1,2) and some others that I've found in TCL
> guides.
> Is it possible to use regex in PL/TCL and can You show me with the exmaple
> how?

> tia
> mazek

> Marcin Mazurek

These links might be useful:
http://www.postgresql.org/docs/aw_pgsql_book/node52.html
http://www.scriptics.com/man/tcl8.4/TclCmd/regexp.htm

Pg uses '~' as the regexp operator, so you can try that instead of the '='.  
Check the first link to see the other pg regexp operators, there are four of
them.

--

- CompTechNews Message Board   http://www.comptechnews.com/ -
- CompTechServ Tech Services   http://www.comptechserv.com/ -
---------- http://www.comptechnews.com/~reaster/ ------------



Sat, 10 May 2003 01:55:05 GMT
 PL/TCL regex string matching

Quote:
> These links might be useful:
> http://www.postgresql.org/docs/aw_pgsql_book/node52.html
> http://www.scriptics.com/man/tcl8.4/TclCmd/regexp.htm
> Pg uses '~' as the regexp operator, so you can try that instead of the '='.  

Pg's regexp package is pretty old and limited --- I believe it just
implements some POSIX spec or other, not all the fancy stuff you find
in TCL or Perl regexps nowadays.

If you need some non-POSIX regexp feature, try making a TCL regexp
function, say

create function tcl_regexp(text,text) returns bool as
'regexp -- $1 $2' language 'pltcl';

Then you use this in SQL queries like

        SELECT ... WHERE tcl_regexp('pattern', variable);

In general, pltcl or plperl make great implementation languages for
text-mashing functions, so I don't feel any big hurry to improve
our built-in SQL functions to try to equal them...

                        regards, tom lane



Sat, 10 May 2003 02:24:02 GMT
 
 [ 3 post ] 

 Relevant Pages 

1. pgsql/src/backend regex/regerror.c regex/regex ...

2. regex matching for Clipper

3. RegEx/Pattern Matching

4. PL/SQL regex

5. debugging Pl/Tcl

6. pgsql/src/pl/tcl (pltcl.c)

7. pgsql/src/pl/tcl pltcl.c

8. pgsql/src/pl/tcl Makefile

9. pl/tcl elog command Unicode patch

10. Patch for pl/tcl Tcl_ExternalToUtf and Tcl_UtfToExternal

11. pgsql/src/pl/tcl pltcl.c

12. pgsql/src/pl/tcl/test test.expected test_queri ...


 
Powered by phpBB® Forum Software