LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Searching for numeric values in PHP (https://www.linuxquestions.org/questions/programming-9/searching-for-numeric-values-in-php-635775/)

TheBeli 04-16-2008 12:00 PM

Searching for numeric values in PHP
 
........remove please

duryodhan 04-16-2008 12:19 PM

http://in2.php.net/manual/en/function.preg-replace.php

should do it.

I think '

$string = 'input text';
$pattern = '/(\w+) (\d)(\d)(\d+)(\w+)/i';
$replacement = '${1}1337$3$4';
echo preg_replace($pattern, $replacement, $string);

graemef 04-16-2008 05:40 PM

A reverse engineering problem...

We have the answer, but what was the question? ;)

jlinkels 04-16-2008 08:40 PM

Since the answer was not '42', the question was not "What is the meaning of life and everything?"

OTOH, maybe there were more answers to that question, and this might be one of them.

jlinkels

graemef 04-16-2008 10:02 PM

Well I believe that there is overwhelming evidence that the answer is 42 but as we know the answer is never as interesting as the question.

duryodhan 04-17-2008 03:55 AM

iirc

he wanted to replace

<text+><digit><digit><more digits><moretext>
with
<text+><digit><digit>1337<moredigits><more text>


All times are GMT -5. The time now is 09:17 AM.