This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Java in General and the fly likes Simple (I hope) regex question Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Simple (I hope) regex question" Watch "Simple (I hope) regex question" New topic
Author

Simple (I hope) regex question

Phil Chuang
Ranch Hand

Joined: Feb 15, 2003
Posts: 251
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

Joined: Feb 15, 2003
Posts: 251
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 ]
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Simple (I hope) regex question
 
Similar Threads
problem in running servlet
Basic Question????
Using PC as server
Servlet Mapping in Tomcat
Adding html tags to script