On Tue, May 25, 2010 at 12:57:53PM -0600, LuKreme wrote:
> OK, trying to sort a file of movie titles.
> 
> This is where I got to:
> 
> Sort using pattern:
> ^(the|A|An|\d+)?\.?\s+?(.*)$

Your regex requires whitespace at the beginning of the actual title, where
you might not have any, and also matches the whitespace non-greedily where
you actually want to match it greedily.  Try this:

^(?:(?:the|a|an)\s+|\d+)?\.?\s*(.*)$


But what you really want to match is an optional number, *followed
by* an optional article, like so:

^(?:\d+\.?\s+)?(?:(?:the|a|an)\s+)?(.*)$


Of course, either way you could have trouble with movie titles that
legitimately start with numbers, such as "12 Angry Men".

Ronald

-- 
You received this message because you are subscribed to the 
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
If you have a feature request or would like to report a problem, 
please email "[email protected]" rather than posting to the group.

Reply via email to