0

I have a string which includes line breaks in java .I need a regular expression to match any characters including line breaks.

Here is the string:

String s= "Hello World".(line break)
       Note= amount"

I am using this (.*?) but it won't match line breaks.

stema
  • 90,351
  • 20
  • 107
  • 135
manzur
  • 33
  • 5

1 Answers1

0

You can try with this pattern:

([a-zA-Z\n])+

Tested on regexr. This is an example of how to implement it in Java

String pattern = "([a-zA-Z\n])+";
String input = "String with \n line break.";
Pattern p = Pattern.compile(pattern);
java.util.regex.Matcher m = p.matcher(input);
IlGala
  • 3,331
  • 4
  • 35
  • 49