Closed Thread Icon

Preserved Topic: PHP's not be nice :( u help be better :) (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=20998" title="Pages that link to Preserved Topic: PHP&amp;#039;s not be nice :( u help be better :) (Page 1 of 1)" rel="nofollow" >Preserved Topic: PHP&#039;s not be nice :( u help be better :) <span class="small">(Page 1 of 1)</span>\

 
Dracusis
Maniac (V) Inmate

From: Brisbane, Australia
Insane since: Apr 2001

posted posted 07-05-2001 03:54

Yup! there's a dum PHP newbie question heading your way!

OK, This may sound a tad confusing...

I need to use the eregi_replace() function to re-format some code. But I also need to specify a pattern that is NOT preceeded with xxxx

Ok, that sounded wrong, let me try again....

So, what I'm looking for would be a way to specify eregi_replace to only act on a this pattern:

"http://([_./a-zA-Z0-9!&%#?,'=:~]+)". "\.". "([_./a-zA-Z0-9!&%#?,'=:~]+)"

(the syntax for the above is fine)

but only if the pattern is NOT preceded with [link= or [link].

I don't know the syntax well enough yet but I do know this this didn't do a dam thing:

"http://(-[nk=])([_./a-zA-Z0-9!&%#?,'=:~]+)". "\.". "([_./a-zA-Z0-9!&%#?,'=:~]+)"

when I was kinda hoping it would... any suggestions... ??


everybody needs a swamp bear

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 07-05-2001 08:41

You should consider using PERL regular expressions, instead of using POSIX regular expressions. Here's how to do that with PERL regular expressions:

<?

// Written by mr.maX, http://www.max.co.yu/
$text = preg_replace("/(?<!\[link(=&#124;\]))((?:https?&#124;ftp):\/\/[^\s\)<'\"]+)/", "<A HREF=\"$2\">$2</A>", $text);

?>

Dracusis
Maniac (V) Inmate

From: Brisbane, Australia
Insane since: Apr 2001

posted posted 07-05-2001 15:08

Execelent..

Yeah, that seems to make sence execpt for two bits...

$text = preg_replace("/(?<!\[link(=

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 07-05-2001 20:13

"https?" is there in order to handle both non-secure (http) and secure (https) http connections.

"[^\s\)<'\"]" instructs it to stop match when it comes to one of the characters defined in this character class.

For more info, perform a search for "PERL-compatible regular expressions" on your favorite search engine. BTW PERL regular expressions are different than POSIX regular expressions, but you should really learn PERL regexes, because they are standard nowadays. Also, read explanation of PERL regex syntax from the PHP manual...

Dracusis
Maniac (V) Inmate

From: Brisbane, Australia
Insane since: Apr 2001

posted posted 07-05-2001 23:30

Cool, Thanks again MAX.

everybody needs a swamp bear

« BackwardsOnwards »

Show Forum Drop Down Menu