Recently made player, a systematic approach to filter selected music files on the sd card and found that there are a lot of useless files are just some of the audio file, using
"^ \ \ w + \ \ d {5,} |. \ \ w"
To filter the song name, but wonder why "b222aa2" This form can also be matched on it? Know how to explain, thank you.<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) -> Reply: Were divided into two portions being vertical The first part ^ \ w + \ d. {5,} ^ \ W + indicates the start by more than one word characters (uppercase and lowercase letters and numbers) \ D represents a digit {5} represents an arbitrary character appears at least five times
Part II \ W a word character
This relationship between the two parts is or is able to match any string of the first portion or the second portion can be matched on a regular b222aa2 is on how to match it? The second part of the character is clearly not the only one, and it matched ^ \ W + -> b / / at least one word character \ D -> 2 / / A number . {5,} -> 22aa2 / / exactly five arbitrary characters
Use on Java regular expression can refer to my translation http://blog.csdn.net/cugbabybear/article/details/14170355 Reply: Upstairs positive solution. . . Reply:
Thank you for reply, according to what you said to understand, I looked at the can really match. But I still have doubts ask you next. I started regular is written like this:
^ \ \ w + \ \ d {5,} | \ \ w
The purpose is to filter out the string at the beginning of the English character and containing five or more digits, but found no filtering out the form, 0604a_3907413nGf, BBC0702_243243223snP, 201206cet4. The first two because it contains "_" reasons not to match, but why 201206cet4 failed to match on it? Or do you have a better expression? Reply: (? Is) ^ (?! [A-z]). *? \ \ D {5,}. * Reply:
Because metacharacter \ w include alphabetic and numeric characters you can \ w to [a-zA-Z] Reply:
If you talk about that 201206cet4 should be able to match those on the ah. ^ \ \ W -> 2 start, matching \ \ D {5,} ---> 01206 number just five matches
Can be proved "^ \ \ w + \ \ d {5,} | \ \ w" does not match "201206cet4". Or is my understanding that because \ \ w + matches directly to the end of the string, and then matching \ \ d {5,} matches when it leads to unsuccessful? Reply:
What do you use the function? Reply:
What is the function you use?
My code is as follows:
music_name = "201206cet4"; Pattern pattern = Pattern.compile ("^ \ \ w + \ \ d {5,} | \ \ w"); Matcher matcher = pattern.matcher (music_name); Judgment matcher.matches () value of false.
Reply:
What do you use the function?
My code is as follows:
music_name = "201206cet4"; Pattern pattern = Pattern.compile ("^ \ \ w + \ \ d {5,} | \ \ w"); Matcher matcher = pattern.matcher (music_name); Judgment matcher.matches () value of false.
matches () function is a regular expression string as a whole to determine whether the 201206 can really match regular on but your regular digital so the back end is not matched subtitles Reply:
What do you use the function?
My code is as follows:
music_name = "201206cet4"; Pattern pattern = Pattern.compile ("^ \ \ w + \ \ d {5,} | \ \ w"); Matcher matcher = pattern.matcher (music_name); Judgment matcher.matches () value of false.
matches () function is a regular expression string as a whole to determine whether the 201206 can really match regular on but your regular rear end is digital so the subtitles do not match
Thank you, you mean the ghost cet engage in, they do not accompany the \ d? Now looks like this error is too obvious. Try again tomorrow, affixed to the end points. Thank you again.
No comments:
Post a Comment