Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Illegal escape character within regex

807589Sep 26 2008 — edited Sep 27 2008
Hey everyone. I've been struggling with this for a little while now and I can't quite figure it out. I've created a REGEX that will replace everything but the domain in a string.

For example, "http://www.cfcoding.com/post.cfm" would be come "cfcoding.com"

Here is what I have:
strLine.replaceAll("^[a-zA-Z0-9\-]+\.[a-zA-Z]{2,3}", "");
The problem is the 2 illegal escape characters, but this seems to work find in a REGEX tester. :-\
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 25 2008
Added on Sep 26 2008
4 comments
1,266 views