[Phpmyadmin-devel] preg vs. ereg

Robin Johnson robbat2 at fermi.orbis-terrarum.net
Sat Aug 18 20:38:57 CEST 2001


Ok, looking under 'Support Requests' (#447076) there is a note about using
ereg instead of preg, so i went back to convert my lone instance of a preg
in the code.

But try as hard as I might, I can't manage to use eregi_replace to do the
same thing as my bit of code.

lib.inc.php3 - line 694
$sql = preg_replace(
	'/\W'.$data[1].'\./i',
	' '.$data[0].'.',
	$sql);

Could somebody else make a suggestion about the query I can use?
my best conversion of the pcre was "[!a-zA-Z0-9_]".$data[1]."\." but that
doesn't work :-(.

I have also realized that my code adds a nasty little bug.
this is the SQL i was using to test the above:
SELECT c.id, s.id FROM classes c, staff s WHERE c.staff = s.id ORDER BY
s.id

now if i change the fields section at the start just slightly, and the
where clause by taking out some of the white space:
SELECT c.id,s.id FROM classes c, staff s WHERE c.staff=s.id ORDER BY s.id

then the ',' in the fields gets replaced with a space, and your perfectly
valid query is now invalid. The same thing happens with the '=' in the
where clause. We need to find a way to preserve the other character that
matched the \W in the pcre as well as add a space after it. I had the \W
in there so that trying to match 's.' would not match 'foods.' . Any
suggestions on this one?

-- 
Robin Hugh Johnson
QTOD: "I used to be an idealist, but I got mugged by reality."
E-Mail     : robbat2 at orbis-terrarum.net
ICQ#       : 30269588 or 41961639
Home Page  : http://www.orbis-terrarum.net/
Time Zone  : Pacific Daylight (GMT - 8)
-----BEGIN GEEK CODE-----
geekcode.com ebb.org/ungeek
GCS/M/IT d-(+) s+:- a--- C++++ 
U++++ L++++ P--(+) W++ K++ PS+ 
N++ w--- O E---- M-(+) V-- Y++ 
PE++ PGP++ t-- 5 X+ R tv- b+++ 
D++ G++ e(*) h! r-- !y+
------END GEEK CODE------
-----PGP INFO----
Key ID:0x7E20DFA1
FingerPrint:
5447C73A 30FB144C 89521B69 2D6A615E 7E20DFA1
----PGP INFO-----





More information about the Developers mailing list