Thread

  1. regexp replace?

    CSN <cool_screen_name90001@yahoo.com> — 2004-05-06T20:59:16Z

    I'd like to create a function that will take strings
    like:
    
    abcdef 'quote1' "quote2" / xyz etc.
    
    and return:
    
    abcdef-quote1-quote2-xyz-etc.
    
    Basically remove all characters that aren't
    [A-Za-z0-9], -, or ., and replace all spaces with
    hyphens. Possible? The only string function that
    supports regular expressions is substring and I
    couldn't make that do what I want.
    
    TIA,
    CSN
    
    
    	
    		
    __________________________________
    Do you Yahoo!?
    Win a $20,000 Career Makeover at Yahoo! HotJobs  
    http://hotjobs.sweepstakes.yahoo.com/careermakeover 
    
    
  2. Re: regexp replace?

    scott.marlowe <scott.marlowe@ihs.com> — 2004-05-06T21:19:26Z

    On Thu, 6 May 2004, CSN wrote:
    
    > I'd like to create a function that will take strings
    > like:
    > 
    > abcdef 'quote1' "quote2" / xyz etc.
    > 
    > and return:
    > 
    > abcdef-quote1-quote2-xyz-etc.
    > 
    > Basically remove all characters that aren't
    > [A-Za-z0-9], -, or ., and replace all spaces with
    > hyphens. Possible? The only string function that
    > supports regular expressions is substring and I
    > couldn't make that do what I want.
    
    I think translate may be able to do what you want pretty handily.  May 
    take two passes, i.e. a subselect.
    
    
    
  3. Re: regexp replace?

    Alvaro Herrera <alvherre@dcc.uchile.cl> — 2004-05-06T22:21:24Z

    On Thu, May 06, 2004 at 01:59:16PM -0700, CSN wrote:
    
    > Basically remove all characters that aren't
    > [A-Za-z0-9], -, or ., and replace all spaces with
    > hyphens. Possible? The only string function that
    > supports regular expressions is substring and I
    > couldn't make that do what I want.
    
    This should be trivial with plperl ... I'd think you are wasting your
    time trying to do it with plpgsql or SQL; this is what Postgres
    flexibility is for!
    
    -- 
    Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
    "Ni aun el genio muy grande llegaría muy lejos
    si tuviera que sacarlo todo de su propio interior" (Goethe)