On Wednesday 11. June 2008, Leif B. Kristensen wrote:
>p := BTRIM(tmp, '#')::INTEGER;
>name := get_person_name(p);
>str := REPLACE(str, tmp, name);
I did some "folding" and replaced the above with
str := REPLACE(str, tmp, get_person_name(BTRIM(tmp, '#')::INTEGER));
and g
For the record: I've got two different flavors of those "shortlinks".
The first one, [p=123|John Smith] is the one that I started this thread
with. The second one is just a person number like [p=123] and should be
expanded to a similar link, with the default person name (fetched by
get_person_n
On Tuesday 10. June 2008, Michael Fuhr wrote:
>Something between my message and your shell appears to have converted
>a few spaces to no-break spaces. A hex dump of your query shows the
>following:
>
> 73 65 6c 65 63 74 20 72 65 67 65 78 70 5f 72 65 |select
> regexp_re| 0010 70 6c
CaT <[EMAIL PROTECTED]> writes:
> There's a bug in your version of pcre I think as postgres would have
> little to do with the regex itself (I be guessing).
You be wrong ... PG uses Tcl's regex engine, not pcre, and this behavior
is as documented. No, I don't know why Henry Spencer chose to do it
On Tue, Jun 10, 2008 at 03:43:02PM +0200, Leif B. Kristensen wrote:
> On Tuesday 10. June 2008, Leif B. Kristensen wrote:
> >Hey, I told it not to be greedy, didn't I?
>
> Found it. I must make *both* atoms non-greedy:
That makes no sense. Take this bit of perl, which works as expected:
$str = '
On Tuesday 10. June 2008, CaT wrote:
>On Tue, Jun 10, 2008 at 03:43:02PM +0200, Leif B. Kristensen wrote:
>> On Tuesday 10. June 2008, Leif B. Kristensen wrote:
>> >Hey, I told it not to be greedy, didn't I?
>>
>> Found it. I must make *both* atoms non-greedy:
>
>That makes no sense. Take this bit
On Tue, Jun 10, 2008 at 07:41:53AM -0600, Michael Fuhr wrote:
> On Tue, Jun 10, 2008 at 02:59:53PM +0200, Leif B. Kristensen wrote:
> > So far, so good. But look here:
> >
> > pgslekt=> select link_expand('[p=123|John Smith] and [p=456|Jane Doe]');
> > link_expand
> >
On Tuesday 10. June 2008, Leif B. Kristensen wrote:
>Hey, I told it not to be greedy, didn't I?
Found it. I must make *both* atoms non-greedy:
pgslekt=> CREATE OR REPLACE FUNCTION link_expand(TEXT) RETURNS TEXT AS
$$
SELECT REGEXP_REPLACE($1,
E'\\[p=(\\d+?)\\|(.+?)\\]',
E
On Tue, Jun 10, 2008 at 02:59:53PM +0200, Leif B. Kristensen wrote:
> So far, so good. But look here:
>
> pgslekt=> select link_expand('[p=123|John Smith] and [p=456|Jane Doe]');
> link_expand
> ---
>
On Tue, Jun 10, 2008 at 02:25:44PM +0200, Leif B. Kristensen wrote:
> Thank you Michael, I figured it was something fishy with the escaping.
> When I try your example, I get
>
> pgslekt=> select regexp_replace(
> pgslekt(> '[p=1242|John Smith]',
> pgslekt(> e'\\[p=(\\d+)\\|(.+?)\\]',
> pgsle
I put the code into a function, link_expand():
CREATE OR REPLACE FUNCTION link_expand(TEXT) RETURNS TEXT AS $$
SELECT REGEXP_REPLACE($1,
E'\\[p=(\\d+)\\|(.+?)\\]',
E'\\2', 'g');
$$ LANGUAGE sql STABLE;
pgslekt=> select link_expand('[p=123|John Smith]');
On Tuesday 10. June 2008, Michael Fuhr wrote:
>Parts of the regular expression need more escaping. Try this:
>
>select regexp_replace(
> '[p=1242|John Smith]',
> e'\\[p=(\\d+)\\|(.+?)\\]',
> e'\\2'
>);
>
> regexp_replace
>---
> J
On Tue, Jun 10, 2008 at 01:28:06PM +0200, Leif B. Kristensen wrote:
> I want to transform the text '[p=1242|John Smith]' to
> John Smith, but what I get is:
>
> pgslekt=> select REGEXP_REPLACE('[p=1242|John Smith]',
> pgslekt(> E'[p=(\d+)|(.+?)]',
> pgslekt(> E'\\2');
> regexp
I want to transform the text '[p=1242|John Smith]' to
John Smith, but what I get is:
pgslekt=> select REGEXP_REPLACE('[p=1242|John Smith]',
pgslekt(> E'[p=(\d+)|(.+?)]',
pgslekt(> E'\\2');
regexp_replace
--
[=1242|John Smith
14 matches
Mail list logo