Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > fr.comp.lang.regexp > #84

Re: Help with RexExp in English?

From Olivier Miakinen <om+news@miakinen.net>
Newsgroups fr.comp.lang.regexp
Subject Re: Help with RexExp in English?
Date 2017-06-12 00:36 +0200
Organization There's no cabale
Message-ID <ohkgkj$1c5d$1@cabale.usenet-fr.net> (permalink)
References <ohhfer$vv5$1@solani.org> <5397fb215ea33b88eb24619edfcc25169f1a0659@news.nemoweb.net> <ohj5ai$ttk$1@solani.org> <ohj7jt$11e9$1@cabale.usenet-fr.net> <ohkc95$n6g$1@solani.org>

Show all headers | View raw


Le 11/06/2017 23:21, Heinz Kesting a écrit :
>> 
>> http://php.net/manual/en/regexp.reference.assertions.php
> 
> My dear, I've read so many of such articles, but somehow I can't get it 
> into my brain! Obviously, Regular Expressions (and French, too!) are two 
> languages my brain seems to be almost incompatible with ... (grin)

;-)

>> Donc :
>> '<a href=((?!</a>).)*<a href='
>> 
>> Ou plus simplement :
>> '<a ((?!</a>).)*<a'

Une espace a été supprimée dans ta réponse, j'avais écrit :
 '<a ((?!</a>).)*<a '
et non :
 '<a ((?!</a>).)*<a'

> Oh yeah, that did the trick! For all cases I could think of and tested 
> up to now, it worked like a charm, perfectly from the very start. By the 
> way, I used the first, 'long' version you proposed, just in case the 
> text might contain '<a' within any other context than a hyperlink.
> So my main mistake seems to be the mix-up or confusion between ^ and ! 
> besides the bracket syntax ...

Quel que soit le contexte, un '<a ' (ne pas oublier l'espace) doit
toujours être suivi d'un '</a>', même si c'est un '<a name=' et pas
un '<a href='.

Mais on peut améliorer ce test en prévoyant aussi la fin de fichier :
'<a ((?!</a>).)*(<a |$)'

Si vraiment tu tiens à la version longue :
'<a href=((?!</a>).)*(<a href=|$)'

> [...]
> 
> So I'd like to say a very big MERCI to you

C'était avec plaisir.


-- 
Olivier Miakinen

Back to fr.comp.lang.regexp | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Help with RexExp in English? Heinz Kesting <Nobody@invalid.invalid> - 2017-06-10 20:57 +0200
  Re: Help with RexExp in English? Duzz' <jsuis@jreste.invalid> - 2017-06-10 20:42 +0000
    Re: Help with RexExp in English? Heinz Kesting <Nobody@invalid.invalid> - 2017-06-11 12:16 +0200
      Re: Help with RexExp in English? Olivier Miakinen <om+news@miakinen.net> - 2017-06-11 12:55 +0200
        Re: Help with RexExp in English? Heinz Kesting <Nobody@invalid.invalid> - 2017-06-11 23:21 +0200
          Re: Help with RexExp in English? Olivier Miakinen <om+news@miakinen.net> - 2017-06-12 00:36 +0200
            Re: Help with RexExp in English? Heinz Kesting <Nobody@invalid.invalid> - 2017-06-16 00:08 +0200
              Re: Help with RexExp in English? Olivier Miakinen <om+news@miakinen.net> - 2017-06-16 01:10 +0200
                Re: Help with RexExp in English? Heinz Kesting <Nobody@invalid.invalid> - 2017-06-18 12:14 +0200
                Re: Help with RexExp in English? Olivier Miakinen <om+news@miakinen.net> - 2017-06-18 19:05 +0200
  Re: Help with RexExp in English? Logan Won-Ki Lee <logan.wonki.lee@gmail.com> - 2021-07-14 12:19 +1000
    Re: Help with RexExp in English? Olivier Miakinen <om+news@miakinen.net> - 2021-07-14 09:23 +0200
      Re: Help with RexExp in English? Otomatic <otomatic@oto.invalid> - 2021-07-14 17:09 +0200

csiph-web