Mailinglist Archive: opensuse-programming (68 mails)

< Previous Next >
Re: [suse-programming-e] Tips for PCRE expressions?
  • From: Mark Gray <markgray-temp-1072781312@xxxxxxxxxxxx>
  • Date: 08 Jan 2004 02:24:41 -0500
  • Message-id: <6swu82zyva.fsf@xxxxxxxxxxxx>
Trey Gruel <drathos-suse@xxxxxxxxxxxxxx> writes:

> I'm trying to implement some data checking using PCRE for regular
> expressions. My experience using regex is fairly limited and very
> rusty. For the most part, I've been able to replace most of the
> simple C based checks with regex, but I'm having trouble with one
> that I think should be possible with regex.

> What I'm having trouble with is a check of an alphanumeric field (up
> to 10 characters) that lets everything *except* UNK, UNKN, and
> UNKNOWN through (logic being if it's unknown, it should be blank).
> I was thinking I should be able to do this with look-ahead or
> look-behind assertion, but I can't seem to make it work.

> Any ideas would be appreciated.

First off, get ahold of a copy of:

Mastering Regular Expressions, 2nd Edition
By Jeffrey E. F. Friedl
2nd Edition July 2002
ISBN 0-596-00289-0, Order Number: 2890
484 pages, $39.95 US, $61.95 CA, 28.50 UK
O'Reilly

Secondly, it is almost always a mistake to try to do all your work
using a single regex -- use multiple regex's and program logic based
on the results.


< Previous Next >
Follow Ups
References