pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rod Taylor <rbt@rbt.ca>
To: Moonstruck <bogus.email@pls-relpy-to.group>
Cc: pgsql-sql@postgresql.org
Subject: Re: Reverse pattern match.
Date: Mon, 18 Aug 2003 19:05:35 -0400
Message-ID: <1061247934.33964.1.camel@jester> (raw)
In-Reply-To: <3f407aa4$0$15136$afc38c87@news.optusnet.com.au>
References: <3f407aa4$0$15136$afc38c87@news.optusnet.com.au>

On Mon, 2003-08-18 at 03:05, Moonstruck wrote:
> I want to create a table of  regular expression patterns (for assessing
> phone numbers), something like:
> CREATE TABLE CallType ( pattern varchar primary key,
>                         type    varchar,
>                         rate    int4);
> INSERT INTO CallType VALUES ('0[3-9]________','Interstate Call',50);
> INSERT INTO CallType VALUES ('9_______','Local Call',25);
> INSERT INTO CallType VALUES ('0011__________%','International Call',100);
> 
> Then determine call types, based on a match, something like:
> 
> 
> PhoneNumber := '99116633';
> SELECT type, rate FROM CallType where pattern LIKE PhoneNumber;

SELECT type, rate FROM CallType WHERE PhoneNumber ~ pattern;

Attachments:

  signature.asc (application/pgp-signature, 186B) download

view thread (4+ messages)  latest in thread

Message-ID: <1061247934.33964.1.camel@jester>
Permalink:  ../1061247934.33964.1.camel@jester/
Also on:    postgresql.org/message-id/1061247934.33964.1.camel@jester

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: rbt@rbt.ca, bogus.email@pls-relpy-to.group
  Subject: Re: Reverse pattern match.
  In-Reply-To: <1061247934.33964.1.camel@jester>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox