Hello ... Can anyone tell me that why I obtained this error that which of the adhering to incorrectly matches the term with its location?
Tbelow are 2 problems here:The regex ofPattern.matcherwill certainly not look for the full string unmuch less you add a leading^(start of regex) and also trailing$(finish of regex).file.getName()will rerotate the name including file extension.
You are watching: Which of the following incorrectly matches the term with its location?
So, there are two feasible solutions:
1) You could adjust the regex of the pattern so the matches does just complement the full file-name:
int count=0;Pattern pattern = Pattern.compile("^" + patternName + "\.?.+$");for(Data f: fileList) Matcher matcher = pattern.matcher(f.getName()); if(matcher.find()) count++; Brief explacountry of the regex:
^NUTS\.?.+$^ $ # Start and finish of the regex, to match the entire file-name NUTS # The file name you want to inspect \.?.* # An (optional) file extension (i.e. `.txt`)2) You can rerelocate the extension, and use an.equals:int count=0;for(Documents f: fileList) String fileNameWithoutExanxiety = f.getName().split("\.")<0>; if(patternName.equals(fileNameWithoutExtension)) count++;
ask associated questioncomment
Your comment on this answer:
|Your name to screen (optional):|
|Email me at this address if a comment is included after mine:Email me if a comment is added after mine|
Privacy: Your email deal with will certainly only be offered for sending these notifications.
What is the shade of the sky?
To protect against this verification in future, please log in or register.
1 answer44 views
Which of the complying with best explains the term "review consistency"?
Problem: This is a dilemma that I require help with: which of the complying with finest explains the term "check out consistency"?
askedApr 1rakib151.5k points
1 answer38 views
Which consistent expression string matches any kind of sequence of personalities of any kind of length?
Problem: What should I perform if I can"t find a solution anywhere: Which consistent expression string matches any kind of sequence of characters of any kind of length?
1 answer1 view
excellent beasts and wbelow to discover them openload
Problem: ======= excellent beasts and wbelow to find them openload
1 answer24 views
Which continuous expression character matches zero or more of the previous character?
Problem: I"d appreciate it if you can respond to this : Which constant expression character matches zero or even more of the previous character?
1 answer13 views
Write a continuous expression which matches a email resolve .
Problem: Is tbelow some means to deal with this? > Write a consistent expression which matches a email attend to .
1 answer23 views
Check if one string is substring of another
Problem: Please,I desire a response : Check if one string is substring of another
1 answer9 views
Check if a string is a substring of an additional string in java
Problem: Can anyone help me via this issue? >Check if a string is a substring of one more string in java.
See more: Consulado Mexicano En Kansas City, Consulado De Carrera De México En Kansas City
1 answer7 views
Find a word in a string java
Problem: uncover a word in a string java.
1 answer8 views
C++ string number of characters
Problem: C++ string variety of characters
1 answer6 views
Count variety of characters in a string c++
Problem: Count variety of personalities in a string c++