Rob Prime wrote:
See if you can put all of this together to form one regex. Make sure to check your year group against null. This will occur if it's not present.
a sarkar wrote:"Old user, new username"
Darryl Burke wrote:
a sarkar wrote:"Old user, new username"
Why, were you taken up for cross posting under the old username?
http://forums.oracle.com/forums/thread.jspa?threadID=1255349
Stephan van Hulst wrote:Except he notified everyone he was cross posting?
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Abhijit
-------
SCJP 5, SCBCD 5, OCWCD 5, OCEWSD 6, CSM
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Rob Prime wrote:- (?:avi|mkv|mp4|divx){1}+ : this is where I have some questions about. First of all, {1} is never needed. It means "exactly one time", which is the same you get if you don't add any quantifiers. But that trailing + is odd. Do you want things like "avimp3divx" to be allowed? Surely not?
Mike Simmons wrote:
Rob Prime wrote:- (?:avi|mkv|mp4|divx){1}+ : this is where I have some questions about. First of all, {1} is never needed. It means "exactly one time", which is the same you get if you don't add any quantifiers. But that trailing + is odd. Do you want things like "avimp3divx" to be allowed? Surely not?
That's not what the + does here. Instead it makes the preceding quantifier possessive. In this case that's {1}, which means exactly once - but now {1}+ means exactly once in possessive mode, disabling backtracking if the first attempt for this part of the expression fails.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Rob Prime wrote:I see that you're using [ and ] to match the extension. That won't work. You should use ( and ), or if you don't want it as a capturing group use (?: and )
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Rob Prime wrote:How about the Javadoc of java.util.regex.Pattern? 90% of what you need for regexes can be found there.
Abhijit
-------
SCJP 5, SCBCD 5, OCWCD 5, OCEWSD 6, CSM
Mike Simmons wrote:
Picking a few movie titles semi-randomly out of imdb.com lists, I see
Wall Street: Money Never Sleeps
Legend of the Guardians: The Owls of Ga'Hoole
Crouching Tiger, Hidden Dragon
Kill Bill: Vol. 1
9 1/2 Weeks
If these were converted into file names by adding an optional (2010) (or other year) and a file extension, would your regex successfully parse them?
Abhijit
-------
SCJP 5, SCBCD 5, OCWCD 5, OCEWSD 6, CSM
a sarkar wrote:
Rob Prime wrote:How about the Javadoc of java.util.regex.Pattern? 90% of what you need for regexes can be found there.
It seems to me that [avi|mkv|mp4|divx] is following straight from the Character class [abc] which means "a, b, or c (simple class)". Why would [avi|mkv|mp4|divx] not work and (avi|mkv|mp4|divx) would?
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Rob Prime wrote:
... a character class matches one single character. You want to match one of a few substrings, and that's what | is for. The () - which can be replaced by (?:) - is used to limit the | to only the things inside them.
Abhijit
-------
SCJP 5, SCBCD 5, OCWCD 5, OCEWSD 6, CSM
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |