Re: [HACKERS] writing new regexp functions

2007-02-02 Thread Jeremy Drake
On Thu, 1 Feb 2007, David Fetter wrote: Yes, although it might have the same name, as in regex_match(pattern TEXT, string TEXT, return_pre_and_post BOOL). The data structure could be something like TYPE matches ( prematch TEXT, matchTEXT[], postmatch TEXT ) I just

Re: [HACKERS] writing new regexp functions

2007-02-02 Thread Jeremy Drake
On Fri, 2 Feb 2007, Jeremy Drake wrote: jeremyd=# select * from regexp_matches('foobarbequebaz', $re$(bar)(beque)$re$, false); prematch | fullmatch | matches | postmatch --+---+-+--- \N | \N| {bar,beque} | \N (1 row) I just changed

Re: [HACKERS] writing new regexp functions

2007-02-02 Thread David Fetter
On Fri, Feb 02, 2007 at 12:54:30AM -0800, Jeremy Drake wrote: On Fri, 2 Feb 2007, Jeremy Drake wrote: jeremyd=# select * from regexp_matches('foobarbequebaz', $re$(bar)(beque)$re$, false); prematch | fullmatch | matches | postmatch --+---+-+---

Re: [HACKERS] writing new regexp functions

2007-02-02 Thread Jeremy Drake
On Fri, 2 Feb 2007, Jeremy Drake wrote: I just coded up for this: CREATE FUNCTION regexp_matches(IN str text, IN pattern text) RETURNS text[] AS 'MODULE_PATHNAME', 'regexp_matches' LANGUAGE C IMMUTABLE STRICT; CREATE FUNCTION regexp_matches( IN str text, IN pattern text,

Re: [HACKERS] writing new regexp functions

2007-02-02 Thread Tom Lane
Jeremy Drake [EMAIL PROTECTED] writes: I want to ask, should I break with following substring's precedent, and put the pattern first (as most people probably would expect), or should I break with perl's precedent and put the pattern second (to behave like substring)? All of SQL's pattern

Re: [HACKERS] writing new regexp functions

2007-02-02 Thread David Fetter
On Fri, Feb 02, 2007 at 08:56:31PM -0500, Tom Lane wrote: Jeremy Drake [EMAIL PROTECTED] writes: I want to ask, should I break with following substring's precedent, and put the pattern first (as most people probably would expect), or should I break with perl's precedent and put the

Re: [HACKERS] writing new regexp functions

2007-02-01 Thread Tom Lane
Jeremy Drake [EMAIL PROTECTED] writes: Is there some specific reason that these functions are static, Yeah: not cluttering the global namespace. I'm not excited about exporting everything that anybody could possibly want access to; that just makes it harder to maintain the code. When you see a

Re: [HACKERS] writing new regexp functions

2007-02-01 Thread Jeremy Drake
On Thu, 1 Feb 2007, Tom Lane wrote: Jeremy Drake [EMAIL PROTECTED] writes: Is there some specific reason that these functions are static, Yeah: not cluttering the global namespace. Is there a reason for not putting your new code itself into regexp.c? Not really, I just figured it would be

Re: [HACKERS] writing new regexp functions

2007-02-01 Thread David Fetter
On Thu, Feb 01, 2007 at 05:11:30PM -0800, Jeremy Drake wrote: On Thu, 1 Feb 2007, Tom Lane wrote: Jeremy Drake [EMAIL PROTECTED] writes: Is there some specific reason that these functions are static, Yeah: not cluttering the global namespace. Is there a reason for not putting your

Re: [HACKERS] writing new regexp functions

2007-02-01 Thread Jeremy Drake
On Thu, 1 Feb 2007, David Fetter wrote: On Thu, Feb 01, 2007 at 05:11:30PM -0800, Jeremy Drake wrote: Anyway, the particular thing I was writing was a function like substring(str FROM pattern) which instead of returning just the first match group, would return an array of text containing

Re: [HACKERS] writing new regexp functions

2007-02-01 Thread David Fetter
On Thu, Feb 01, 2007 at 10:16:54PM -0800, Jeremy Drake wrote: On Thu, 1 Feb 2007, David Fetter wrote: On Thu, Feb 01, 2007 at 05:11:30PM -0800, Jeremy Drake wrote: Anyway, the particular thing I was writing was a function like substring(str FROM pattern) which instead of returning just