JAVA
java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//https://www.sololearn.com/Discuss/1382436/?ref=app
import java.util.regex.Matcher;
import java.util.regex.Pattern;
class Demo
{
public static void main(String args[])
{
//case insensitive pattern
Pattern pattern1=
Pattern.compile("ab*",Pattern.CASE_INSENSITIVE);
Matcher m1=pattern1.matcher("abxyabtyabykabxyzAB");
while (m1.find())
System.out.println("Case insensitive pattern found from "+m1.start()+" to "+(m1.end()-1));
// case sensitive pattern
Pattern pattern2 = Pattern.compile("ab*");
Matcher m2= pattern2.matcher("abxyabtyabykabxyzAB");
while(m2.find())
System.out.println("Case sensitive pattern found from "+m2.start()+" to "+(m2.end()-1));
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run