*
The moose likes Java in General and the fly likes Simple (I hope) regex question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
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://aspose.com/file-tools
 
subject: Simple (I hope) regex question
 
Similar Threads
problem in running servlet
Basic Question????
Servlet Mapping in Tomcat
Using PC as server
Adding html tags to script