0

I got this String s="<tr><td>Myval";

I want to replace all Strings that is before "<td>" & include "<td>" to "";

 s=replaceAll("*.<td>",s);

So the result should be s="Myval" But it got Runtime error.

   12:39:31.035 [ERROR]  Uncaught exception escaped
java.util.regex.PatternSyntaxException: Dangling meta character '*' near index 0 
*.<td> 

How to fix?

Tum
  • 3,614
  • 5
  • 38
  • 63

1 Answers1

1

In regular expressions, * quantifies the expression coming before it. Here, you've put a * at the beginning of the pattern, which is meaningless.

Maybe you wanted ".*<td>".

guest
  • 6,450
  • 30
  • 44