So I've a case like this
<> = 1
<><> = 2
<<>> = 2
<<test<> = 1
How do I find all of the "<>" it's inside the "<>" as well using regular expression?
Here's code that I've tried.
import java.io.IOException;
import java.util.regex.*;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws IOException {
Scanner s = new Scanner(System.in);
String input = s.nextLine();
Pattern p = Pattern.compile("<(.*?)>");
Matcher m = p.matcher(input);
int count = 0;
while(m.find()){
count++;
}
System.out.println(count);
}
}