• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Simple (I hope) regex question

 
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm working on writing an http tunnel kind of servlet, and I need some help with url replacement.
I'm using a Map to translate from an alias to an address.
So, for the alias "blah" and the address "blah.com"
I want to replace all href links such that
<a href="http://blah.com/hello.html"> --> <a href="http://localhost/blah/hello.html">
OR
<a href="hello.html"> --> <a href="http://localhost/blah/hello.html">
Can someone help me out with a regex pattern or patterns that will match
<a href=" + http:// + aliasAddress OR
<a href=" + not http://
I've got the pattern for the first one, the problem is the 2nd one.
[ September 23, 2003: Message edited by: Phil Chuang ]
 
Phil Chuang
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just to clarify:
If the full URI is
http://localhost/tunnel/blah/
and the alias is
http://www.blah.com:8080
then I want to replace all links like this:
<a href="http://www.blah.com:8080/hello.html"> --> <a href="http://localhost/tunnel/blah/hello.html">
<a href="hello.html"> --> <a href="http://localhost/tunnel/blah/hello.html">
but not like this:
<a href="http://www.blah2.com/">
[ September 23, 2003: Message edited by: Phil Chuang ]
[ September 23, 2003: Message edited by: Phil Chuang ]
reply
    Bookmark Topic Watch Topic
  • New Topic