The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 19, 2019, 02:29:13 PM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: clean urls baby  (Read 4050 times)
m0nkeymafia
Expert
****
Offline Offline

Posts: 240


Check it!


View Profile
« on: September 03, 2007, 08:26:59 AM »

first of all you guys rock, i actually freel [more] comfortable with regex now after you guys helpin me
anyway i know this is lame but im well happy so should post anyway

in order to get clean urls, i.e. say a link to an article but without the crap you dont want like brackets and whatnot i used to do a str_replace on abunch of bad character, and i thought that was snazzy.

but it dawned on me that I could use a simple regex to do it, simply by doing ereg_replace('(^[A-z]+)','',$var); will remove all non characters from $var, which is uber cool! btw im writing that regex from memory it may be slightly off, but still, i thought id share the love

ta ta
Logged

I am Tyler Durden
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #1 on: September 03, 2007, 09:11:13 AM »

Congrats on the Regex strength MM - it does rock.

And BTW you're right, the regex _replace functions are really handy - may I ask why you went with ereg_replace rather than preg_replace? I thought from my reading that overall the preg_ functions were safer... thoughts?
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
m0nkeymafia
Expert
****
Offline Offline

Posts: 240


Check it!


View Profile
« Reply #2 on: September 03, 2007, 09:48:15 AM »

well my regex skills are to the point where I can cobble something together, i dont really know the difference between the two
what is the difference? lol
Logged

I am Tyler Durden
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #3 on: September 03, 2007, 09:53:36 AM »

Well, the dox say the ereg are "Posix Extended" WTF that means... but all over the dox page it points to the preg functions which are PERL compatible and seem to be more active in both discussion and capabilities. I've just always used them because the tone of the ereg funcs seemed either specialized or in some way less robust...

Looking for anyone with an opinion here... WebProfessor perhaps?
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
vsloathe
vim ftw!
Global Moderator
Lifer
*****
Offline Offline

Posts: 1669



View Profile
« Reply #4 on: October 09, 2007, 01:51:48 PM »

In another language I use, I pretty much always set the flag to return the results of a StringRegex() in PHP/Perl mode. FWIW
Logged

hai
nutballs
Administrator
Lifer
*****
Offline Offline

Posts: 5627


Back in my day we had 9 planets


View Profile
« Reply #5 on: October 09, 2007, 07:21:05 PM »

posix extended means you can do this i think.
[[:digit:]]

not worth it. preg_XXXXXXX is faster from what I have read and in my quick simple testing.
Logged

I could eat a bowl of Alphabet Soup and shit a better argument than that.
m0nkeymafia
Expert
****
Offline Offline

Posts: 240


Check it!


View Profile
« Reply #6 on: October 11, 2007, 08:40:31 AM »

nice one balls
Logged

I am Tyler Durden
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!