Re: PHP Newbie - RegEx
by "Billy O'Connor" <billyo(at)kennetweb.co.uk>
|
Date: |
Sat, 6 Jul 2002 09:18:03 +0100 |
To: |
"Hank Marquardt" <hmarq(at)yerpso.net> |
Cc: |
<hwg-servers(at)hwg.org> |
References: |
work yerpso |
|
todo: View
Thread,
Original
|
|
Many thanks Hank. That has worked!
I now seem to have another problem...
Bill.
--
Billy O'Connor
Kennet Web
~~~~~~~~~~~~~~~~~~~
Web Design & Hosting
Solutions For Business
~~~~~~~~~~~~~~~~~~~~~
T: 07021 107 411
E: billyo(at)KennetWeb.co.uk
W: http://www.KennetWeb.co.uk
----- Original Message -----
From: "Hank Marquardt" <hmarq(at)yerpso.net>
To: "Billy O'Connor" <billyo(at)kennetweb.co.uk>
Cc: <hwg-servers(at)hwg.org>
Sent: Friday, July 05, 2002 3:57 PM
Subject: Re: PHP Newbie - RegEx
> Bill --
>
> If you were writing perl, you'd be darned close:) ... PHP has no regex
> *operators* ... they are functions -- have a peek here:
>
> http://www.php.net/preg_match
> http://www.php.net/preg_replace
>
> ... change your if construct to this:
>
> if(preg_match('/[0-9]+/',$ID)) {
> do this
> } else
> {
> do this
> }
>
> HTH,
>
> Hank
>
> On Fri, Jul 05, 2002 at 02:31:44PM +0100, Billy O'Connor wrote:
> > Hi,
> >
> > I'm having trouble doing a simple regex in PHP and wonder if anyone can
> > help?
> >
> > Can someone tell me how I find out if a variable contains a digit? I
have a
> > script that is passed either a digit or URL's. If the variable contains
a
> > digit, I want the script to extract info from a database, else if it is
a
> > URL, go to the URL.
> >
> > I've tried this, amongst other things and just cannot figure it out....
> >
> > if ($ID =~ /[0-9]/) {
> > do this
> > } else {
> > do this
> > }
> >
> > I hope someone can help.
> >
> > ATB,
> >
> > Bill.
> > --
> > Billy O'Connor
> >
> > Kennet Web
> > ~~~~~~~~~~~~~~~~~~~
> > Web Design & Hosting
> > Solutions For Business
> > ~~~~~~~~~~~~~~~~~~~~~
> > T: 07021 107 411
> > E: billyo(at)KennetWeb.co.uk
> > W: http://www.KennetWeb.co.uk
> >
> >
>
> --
> Hank Marquardt <hank(at)yerpso.net>
> http://web.yerpso.net
> GPG Id: 2BB5E60C
> Fingerprint: D807 61BC FD18 370A AC1D 3EDF 2BF9 8A2D 2BB5 E60C
> *** Web Development: PHP, MySQL/PgSQL - Network Admin: Debian/FreeBSD
> *** PHP Instructor - Intnl. Webmasters Assn./HTML Writers Guild
> *** Beginning PHP && PHP II -- Starting March 25, 2002
> *** See http://www.hwg.org/services/classes
HWG: hwg-servers mailing list archives,
maintained by Webmasters @ IWA