OVH Cloud OVH Cloud

Replace characters on html using regex????

1 réponse
Avatar
AjalaDeveloper
Hello people, I'm trying to do something very easy (I think so!). I'm
using Java regular expression to remove-> // in an html code, for
example in the next example, I would like to replace // with /, but
only those wich aren't next to http:
---------------------------------------------------------------------------=
=AD---------

<img src=3D"http://example.com//img/img.jpg>
---------------------------------------------------------------------------=
=AD---------

I have problems in this example, just because I don't want to remove //

which are next to http:

I'd like to get: <img src=3D"http://example.com/img/img.jpg>. I'm trying
wih the next java code:
---------------------------------------------------------------------------=
=AD---------

completeHtml =3D completeHtml.replaceAll("(?!http://)//*","/");
---------------------------------------------------------------------------=
=AD---------

I'm getting as result this: <img src=3D"http:/example.com/img/img.jpg">.
I don't want to lose a / in http://=20


Please help me! Tk you

1 réponse

Avatar
Patrice Karatchentzeff
"AjalaDeveloper" writes:

[...]

Please help me! Tk you


Easy. When you post in fr.comp.lang.perl, that means that you have
to:

- post in French language
- talk about Perl

Hope it can help,

PK


--
      |      _,,,---,,_       Patrice KARATCHENTZEFF
ZZZzz /,`.-'`'    -.  ;-;;,_   mailto:
     |,4-  ) )-,_. , (  `'-'  http://p.karatchentzeff.free.fr
    '---''(_/--'  `-'_)