I tried this with a regex tester and it works. But why can't i get it work for JAVA.
I am hoping to search for neither..........nor
I want to count how many neither
somethingnor
are in a string : "Neither u or me are human"
.
I have tried :
occurrence += sentence.split( "(?i)\\Wneither.+nor\\W" ).length - 1;
but it is not working because the output System.out.print(occurrence)
result is 0
.
I thought \\W
stands for non-word character while .+
means any character(s).
How can I get a occurrence
result of 1
?