Toon posts:

[regex] Alle links naar nieuwe window's

Pagina: 1
Acties:

Verwijderd

Topicstarter
Ik probeer een regex te maken om te kijken of links naar nieuwe windows voorkomen in de html van een pagina.
Maar een link naar _self, _parent of _top moet hij niet naar kijken

ik heb nu dit:
code:
1
2
$galleryhtml = "<a href=\"http://www.google.com\" target =\"_self\">test</a>";
preg_match_all("/<a ([^>]*)target(.*?)=(.*?)([\"\'])(_self|_parent|_top)([\"\'])([^>]*)>(.*?)<\/a>/is", $galleryhtml, $matches);

Maar hij moet dus net andersom, en dat lukt dus niet.

  • NMe
  • Registratie: Februari 2004
  • Laatst online: 15-04 22:07

NMe

Quia Ego Sic Dico.

In plaats van _self|_parent|top gewoon kijken of er _blank staat? Of denk ik nou te simpel? :?

'E's fighting in there!' he stuttered, grabbing the captain's arm.
'All by himself?' said the captain.
'No, with everyone!' shouted Nobby, hopping from one foot to the other.


Verwijderd

Topicstarter
-NMe- schreef op maandag 25 april 2005 @ 13:46:
In plaats van _self|_parent|top gewoon kijken of er _blank staat? Of denk ik nou te simpel? :?
nee want je kan ook naar _piet ofzo linken
en gaat ie naar het window met de naam piet, en dat is ook een popup

  • BtM909
  • Registratie: Juni 2000
  • Niet online

BtM909

Watch out Guys...

Verwijderd schreef op maandag 25 april 2005 @ 13:48:
[...]

nee want je kan ook naar _piet ofzo linken
en gaat ie naar het window met de naam piet, en dat is ook een popup
Nee, want een verwijzing naar een window name doe je niet met underscore :)

Ace of Base vs Charli XCX - All That She Boom Claps (RMT) | Clean Bandit vs Galantis - I'd Rather Be You (RMT)
You've moved up on my notch-list. You have 1 notch
I have a black belt in Kung Flu.


Verwijderd

Topicstarter
BtM909 schreef op maandag 25 april 2005 @ 13:49:
[...]

Nee, want een verwijzing naar een window name doe je niet met underscore :)
naja, zonder underscore dan ;)

  • NMe
  • Registratie: Februari 2004
  • Laatst online: 15-04 22:07

NMe

Quia Ego Sic Dico.

Misschien iets met negative lookahead assertion?
PHP:
1
preg_match_all("/<a ([^>]*)target(.*?)=(.*?)([\"\'])(?!_self|_parent|_top)([\"\'])([^>]*)>(.*?)<\/a>/is", $galleryhtml, $matches);

'E's fighting in there!' he stuttered, grabbing the captain's arm.
'All by himself?' said the captain.
'No, with everyone!' shouted Nobby, hopping from one foot to the other.


Verwijderd

Topicstarter
nee, dat werkt niet :(

Verwijderd

Topicstarter
ah wacht, er moest nog (.*?) bij :)
nu werkt ie wel
thanks

  • NMe
  • Registratie: Februari 2004
  • Laatst online: 15-04 22:07

NMe

Quia Ego Sic Dico.

Kun je de uiteindelijke regexp even posten? Dan heeft iemand anders er misschien nog wat aan als hij via de search dit topic vindt. :)

'E's fighting in there!' he stuttered, grabbing the captain's arm.
'All by himself?' said the captain.
'No, with everyone!' shouted Nobby, hopping from one foot to the other.

Pagina: 1