Java regex replace

As an example code I would like to verify that the code below is technically correct Java code.

The code is meant to take a string:
<a href=abc><a href=abc><a href=abc>

And replace all instances of <a href...> with x<a href...>y

The purpose it serves is to verify I have the correct syntax for regex within Java.  Please make note of the backreference $0 and the doubling of the \ character in the pattern, I want to make sure both are correct for use in Java.
import java.util.regex.Pattern;
import java.util.regex.Matcher;
class Module1{
  public static void main(String[] asd){
  String sourcestring = "<a href=abc><a href=abc><a href=abc>";
  Pattern re = Pattern.compile("<a\\s+href=[^>]+>",Pattern.CASE_INSENSITIVE | Pattern.DOTALL);
  Matcher m = re.matcher(sourcestring);
  String result = m.replaceAll("x$0y");

Open in new window

LVL 27
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

To the best of my knowledge (University level of Java), this is the exact way I use Regex (of course I would not use regex for this example though. lol).

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ddrudikAuthor Commented:
Ryan_Kempt, I can't say I would use it for that purpose either, but I appreciate the vote of confidence in the example code.  Thanks.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.