dswp.de
http://www.dswp.de/old/

PHP regep help pls :)
http://www.dswp.de/old/forum-gameserver-support/php-regep-help-pls-t1327.html
Page 1 of 1

Author:  dmmh [ 11.08.09 ]
Post subject:  PHP regep help pls :)

need some help with a regular expression

I need to filter text for something like:
tabel 2.1
So it needs to catch that entire piece of text (actually where the word 'table' starts and ends I guess) AND then I want the number (2.1) stored seperately in a variable so I can access it.

help? :D

Author:  dmmh [ 11.08.09 ]
Post subject:  Re: PHP regep help pls :)

thanks for the help cunts

figured it out :)

Code:
$haystack = 'voor een gebruiksfunctie in tabel 2.5 voorschriften zijn'; //example text
$match = '#b(tabel)(s{1})([0-9.]{1,})#'; //(first match the word 'tabel') (second match a single whitespace character) (third match a word which consists of numbers and dots only) -->matches stored in variables ordered in the sequence they are indexed/ started
$replace = "<a href="#" onClick="javascriptwinBRopen('view/table/?tabel_nr=$3', '', 800, 600, 0, 0, 0, 0)">$1$2$3</a>";
return preg_replace($match, $replace, $haystack);
 

Author:  wurst [ 11.09.09 ]
Post subject:  Re: PHP regep help pls :)

:)

Author:  SvaRoX [ 11.09.09 ]
Post subject:  Re: PHP regep help pls :)

Wow you still found time to get the regex working despite 10 hours spent on the server slicing people ? tdm-player58793 - gg ;)

Author:  dmmh [ 11.13.09 ]
Post subject:  Re: PHP regep help pls :)

SvaRoX wrote:
Wow you still found time to get the regex working despite 10 hours spent on the server slicing people ? tdm-player58793 - gg ;)


ahah, I was mostly in spectator :D

love coding :D
and frigging love ajax in combination with PHP...powerrrrrrrrrrrrr

Author:  SanHolo [ 12.17.09 ]
Post subject:  Re: PHP regep help pls :)

I know this is an old topic, just stumbled upon it. Your RegEx is a little weird and the "." actually matches anything (not just a literal dot), so I bet that it does not work on the following string:

"this tabel is tabel 3.2"

You can simply use:

Code:
#b(tabel)s+(&#91;d.&#93;+)#


:)

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/