X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 26455D1B8A2 for ; Mon, 18 Aug 2003 20:05:34 -0300 (ADT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 02264-04 for ; Mon, 18 Aug 2003 20:05:26 -0300 (ADT) Received: from mailav.tor1.inquent.com (mail.inquent.com [216.208.117.106]) by svr1.postgresql.org (Postfix) with ESMTP id D05CAD1B8A1 for ; Mon, 18 Aug 2003 20:05:22 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by mailav.tor1.inquent.com (Postfix) with ESMTP id D312E1024D; Mon, 18 Aug 2003 18:57:42 -0400 (EDT) Received: from [192.168.1.200] (dyn-133-83.tor.dsl.tht.net [134.22.133.83]) by mailav.tor1.inquent.com (Postfix) with ESMTP id BAFE910248; Mon, 18 Aug 2003 18:57:40 -0400 (EDT) Subject: Re: Reverse pattern match. From: Rod Taylor To: Moonstruck Cc: pgsql-sql@postgresql.org In-Reply-To: <3f407aa4$0$15136$afc38c87@news.optusnet.com.au> References: <3f407aa4$0$15136$afc38c87@news.optusnet.com.au> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-QCV2TZY9HzFe4QkcffCf" Message-Id: <1061247934.33964.1.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.4 Date: Mon, 18 Aug 2003 19:05:35 -0400 X-Virus-Scanned: by AMaViS perl-11 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/209 X-Sequence-Number: 14825 --=-QCV2TZY9HzFe4QkcffCf Content-Type: text/plain Content-Transfer-Encoding: quoted-printable 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); >=20 > Then determine call types, based on a match, something like: >=20 >=20 > PhoneNumber :=3D '99116633'; > SELECT type, rate FROM CallType where pattern LIKE PhoneNumber; SELECT type, rate FROM CallType WHERE PhoneNumber ~ pattern; --=-QCV2TZY9HzFe4QkcffCf Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2 (FreeBSD) iD8DBQA/QVu+6DETLow6vwwRAopZAJ9h29JIsjocSv76Ypwu1ylDTUe6kgCdFmtm o8PARX9Vg1BhZaXo9udcuzw= =M+At -----END PGP SIGNATURE----- --=-QCV2TZY9HzFe4QkcffCf--