Hallo Olivier,
Sorry to keep you waiting for so long for my reply, but I really didn't
find the time to get back to this until now.
> 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='.
>
I am not sure if I understood what you're trying to point at here, but
since I am using the 'long' version of your solution, I guess (and hope)
it doesn't matter here.
> 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=|$)'
>
If I understand correctly what you're doing here, then you make sure
that we will have a match even if the string "<a href=" is at the very
end of the text we're testing it on, right?
But that won't be happening - if a hyperlink is inserted, it will always
be something in the following pattern:
... some other text before a <a href="LINK_KEY_VALUE1">linked text
passage</a> appears and then any more text ...
where LINK_KEY_VALUE1 would be the value the programme would be looking
for (and jump to, if found) while the 'linked text passage' would be the
text in the web interface which would appear underlined to show that
this is a link to click on. So the text we're testing the RegExp on will
always end with some normal characters, or if the last word would be a
hyperlink, it would actually end with </a>, but never with a "<a href="
So, as I understand your change to the RegExp, it would not be necessary
to test for the possible ending "<a href=".
What I am trying to avoid with this RegExp formula is something like:
<a href="LINK_KEY_VALUE1">linked text <a
href="LINK_KEY_VALUE2">passage</a></a>
where two consecutive beginning tags of a hyperlink appear before an
ending tag. This might happen if the user who creates the links
highlights a text passage which is already part of a hyperlink - in this
example 'linked text passage' is already linked to 'LINK_KEY_VALUE1',
and now the word 'passage' is highlighted again and given a link to
'LINK_KEY_VALUE2', which doesn't make sense.
But since I can not prevent the user from highlighting any text
passages, I can only test AFTER the link has been created, if the syntax
of the new link is valid, like the following example:
<a href="LINK_KEY_VALUE1">linked text</a> <a
href="LINK_KEY_VALUE2">passage</a>
Here the text passage 'linked text' is linked to LINK_KEY_VALUE1 and the
word 'passage' is linked to LINK_KEY_VALUE2, no consecutive beginning
tags, but each beginning tag is followed by an ending tag before the
next begining tag appears.
I hope you can understand what I am meaning ...
Thanks again for your great support!
Kind reagrds, Heinz