find two option but dont repeat

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
User avatar
visonardo
Forum Contributor
Posts: 136
Joined: Mon Oct 02, 2006 7:49 pm
Location: Argentina, South America´s Sun.

find two option but dont repeat

Post by visonardo »

i need test if the address works in a site, may be that these urls are writen simple like (without *) *http://domine.some/folder/file.extention
or thus <a href="url">url</a>

the problem is that in some cases the links are thus <a href="url">word!=url</a> if i find some <a href="url"> i replace it by the same but then of href=url> an image red or green depending if that work (the url), then if i search that are simplely wroten as i shown first may be that i find again the same url but between a tags and put again the image, and in this case would has two time the image, it would appear thus ImageImagehttp://url.some

and i dont want thus, my regex is it

Code: Select all

$tutu=preg_replace_callback("/((<\s*a\s+[^>]*href\s*=\s*(((\"|'|`)".$value[0]."\\5)|(".$value[0]."))[^>]*>)|(".$value[0]."))/i","bot",$tutu);
how i would do to fix that?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I can't understand what you're asking about.
User avatar
GeertDD
Forum Contributor
Posts: 274
Joined: Sun Oct 22, 2006 1:47 am
Location: Belgium

Post by GeertDD »

Yeah, some proper punctuation wouldn't do any harm. I don't completely get what you mean to say neither. A few notes already though.

Where does $value[0] come from? I guess it contains a url, or the regex for a url?

Also note that if your regex subject contained valid html (e.g. quotes around the attribute values), you could simplify the current regex already.
Post Reply