Matching First Alphanumeric Character skipping (The |An? )

Posted by TheLizardKing on Stack Overflow See other posts from Stack Overflow or by TheLizardKing
Published on 2010-04-10T20:48:43Z Indexed on 2010/04/10 23:23 UTC
Read the original article Hit count: 274

Filed under:
|
|

I have a list of artists, albums and tracks that I want to sort using the first letter of their respective name. The issue arrives when I want to ignore "The ", "A ", "An " and other various non-alphanumeric characters (Talking to you "Weird Al" Yankovic and [dialog]). Django has a nice start '^(An?|The) +' but I want to ignore those and a few others of my choice.

I am doing this in Django, using a MySQL db with utf8_bin collation.

EDIT

Well my fault for not mentioning this but the database I am accessing is pretty much ready only. It's created and maintained by Amarok and I can't alter it without a whole mess of issues. That being said the artist table has The Chemical Brothers listed as The Chemical Brothers so I think I am stuck here. It probably will be slow but that's not so much of a concern for me as it's a personal project.

© Stack Overflow or respective owner

Related posts about python

Related posts about mysql