You are here: DEVPPL Forum Programming PHP and MySQL Forum Script-archive
NOTIFICATIONS
54.094
MEMBERS
15.688
TOPICS
62.262
POSTS
  562
FLASH GAMES
7.740
TUTORIALS
 

Login

E-mail:
Password:

How to avoid RegEx

Share your completed scripts.
0

Loading

How to avoid RegEx

Postby HotNoob » Wed Sep 22, 2010 4:21 am

I thought that i'd post this up.
While looking back at some of my scripts, i found this interesting way around for people who are preg_replace/regular expression retarded like most of us :D

Code: Select all
<?php

$meebo = $_POST['meeboRoom'];
$patterns = array(
                '<div style=\"width:',
                'px\"><style>.mcrmeebo { display: block; background:url(\"http://widget.meebo.com/r.gif\") no-repeat top right; } .mcrmeebo:hover { background:url(\"http://widget.meebo.com/ro.gif\") no-repeat top right; } </style><object width=\"',
                '\" height=\"',
                '\" ><param name=\"movie\" value=\"http://widget.meebo.com/mcr.swf?id=',
                '\"/><embed src=\"http://widget.meebo.com/mcr.swf?id=',
                '\" type=\"application/x-shockwave-flash\" width=\"',
                '\" height=\"',
                '\" /></object><a href=\"http://www.meebo.com/rooms\" class=\"mcrmeebo\"><img alt=\"http://www.meebo.com/rooms\" src=\"http://widget.meebo.com/b.gif\" width=\"',
                '\"height=\"45\" style=\"border:0px\"/></a></div>',
                '\" style=\"border:0px\"/></a></div>');
$meebo = str_replace($patterns, " ", $meebo);
$array = explode(" ", $meebo);

$meebo_id = $array[5];

?>


As you can see, by combining the explode function, you can put all of your unassigned variables in an array and then call them almost like you were using preg_replace/match.

:D

In fact, your results are essentially the same, with 10 times less of a head ache.

Of course tho, it does have its limitations :(
ps, i have never tested the efficiency of this script, so don't ask :(
HotNoob
 
Reputation: 0
Posts: 169
Joined: Sun May 02, 2010 2:38 am
Highscores: 0
Arcade winning challenges: 0

How to avoid RegEx - Sponsored results

Sponsored results

Login to get rid of ads

 

cron
^ Back to Top