pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Papp Gyozo <pgerzson@freestart.hu>
To: Wesley Leonard <marshall@pacdemon.org>
To: beloshapka@mnogo.ru
Cc: pgsql-php@postgresql.org
Subject: Re: Re: data type casting to numbers with intval() or doubleval()
Date: Fri, 16 Nov 2001 08:15:06 +0100
Message-ID: <023601c16ea8$4c4c1460$01fdfea9@jaguar> (raw)
References: <Pine.OSF.3.96.1010322172104.28810A-100000@student.cs.ucc.ie>
	<00cf01c0b307$02ac4080$543987cf@corp.peoplesoft.com>
	<09fd01c0ce65$ccd14760$e875f718@imago>
	<3AE843D0.AF0C8010@pacdemon.org>

> I think a regex would be most appropriate here:
> 
> <?php
> 
> $my_string = "mmm444";
> 
> $my_integer = intval(eregi_replace("[a-z]", "", $my_string));
> 
> print $my_integer;
> 
> ?>
> 
> This removes all letters and takes the int value.  In perl you can remove
> everything that's NOT a digit but I didn't figure that out in PHP yet...  this
> should do for now.

you're thinking of something like:

 $my_integer = intval(preg_replace('!\D+!', '', $my_string));

aren't you?

PCRE regular expression finctions are PERL compatible reg. functions 
using PCRE library.




view thread (3+ messages)

Message-ID: <023601c16ea8$4c4c1460$01fdfea9@jaguar>
Permalink:  ../023601c16ea8$4c4c1460$01fdfea9@jaguar/
Also on:    postgresql.org/message-id/023601c16ea8$4c4c1460$01fdfea9@jaguar

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: pgerzson@freestart.hu, marshall@pacdemon.org, beloshapka@mnogo.ru
  Subject: Re: data type casting to numbers with intval() or doubleval()
  In-Reply-To: <023601c16ea8$4c4c1460$01fdfea9@jaguar>
  References: <Pine.OSF.3.96.1010322172104.28810A-100000@student.cs.ucc.ie> <00cf01c0b307$02ac4080$543987cf@corp.peoplesoft.com> <09fd01c0ce65$ccd14760$e875f718@imago> <3AE843D0.AF0C8010@pacdemon.org> <023601c16ea8$4c4c1460$01fdfea9@jaguar>

* 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