Re: ereg_replace with user defined function?
| From: | Roman Neuhauser | Date: | Wed, 11 Oct 2006 15:39:30 +0000 |
| Subject: | Re: ereg_replace with user defined function? | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-242974@lists.php.net to get a copy of this message | ||
# frank.arensmeier@nikehydraulics.se / 2006-10-11 14:28:21 +0200:
> Actually, - believe it or not - I have never written a class (I am
> still learning PHP after three years working with that language). So
> I am not quite sure of the benefits of your class.
Nevermind then. I don't know how to fit my experience into a short
email, so I'm not going to explain it, just replace the class with
whatever pays the bill.
> Let me try to sum up:
>
> With a preg_replace_callback I am able to look for a pattern like: a
> number ( float or integer ) followed by whitespace followed by one,
> two, three or more characters, followed by a closing character.
>
> e.g.: "((\d{1,10}[,|.]*\d{0,10})*(\s)(\D{1,3})([$|\s|.|,|\)|/]+|$))" (untested)
that's wrong unless you want e. g. these to match:
1|2|3|4 (^)
000000|,.|||| ~!@X
> If preg finds a match, it will pass an array to the specified
> function. In that function I evaluate the unit, see if it is in my
> array containing the conversion "table". If that is the case,
> calculate the new value and return everything. Right?
Yes.
> I will get back with this new approach.
>
> BTW, 0.32/0.34 seconds includes: calling the original html page from
> an outside server, loading this page into the DOM parser
(...) ok then
--
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man. You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991