Java Regex for Trademark Symbol Validation

In this java regex example, we will learn to match trademark symbol ™.

The Unicode code point U+2122 represents the “trademark sign” character. You can match this with “\u2122”, “\u{2122}”, or “\x{2122}”, depending on the regex flavor you’re working with.

Solution java regex : \u2122

String data1 = "Searching in trademark character ™ is so easy when you know it.";
  String regex = "\u2122";
  Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
  Matcher matcher = pattern.matcher(data1);
  while (matcher.find())
     System.out.print("Start index: " + matcher.start());
     System.out.print(" End index: " + matcher.end() + " ");


Start index: 33 End index: 34 ™

Happy Learning !!

Leave a Reply

Inline Feedbacks
View all comments

About Us

HowToDoInJava provides tutorials and how-to guides on Java and related technologies.

It also shares the best practices, algorithms & solutions and frequently asked interview questions.

Our Blogs

REST API Tutorial