How to replace the following line in Java:
Sports videos (From 2002 To 2003) here.
FROM
Sports videos 2002 2003 here.
I have a usage code, but it deletes the entire line, i.e.
I get this conclusion: Sports videos here.
String pattern= "\\((From)(?:\\s*\\d*\\s*)(To)(?:\\s*\\d*\\s*)\\)"; String testStr = "Sports videos (From 2002 To 2003) here."; String testStrAfterRegex = testStr.replaceFirst(pattern, "");
What is missing here?
thanks
VARIOUS LINE WITH DATE FORMAT
If the above line has a date format, for example ( \\ ) or any other character / words, then a digit, the answer will not work
I am replacing the original answer with this template and it will work
String pattern= "\\((From)(.*)(To)(.*)\\)";
source share