[pmwiki-users] Alphabetize by Title Without Leading Articles or Special Characters
pmwiki at solidgone.com
Sun Mar 20 20:12:06 CDT 2016
Also, as reference, this website http://regexr.com/ is really helpful in
explaining what a regex is going to do. Over over each element and it'll
explain what that element means. Click the Explain tab at the bottom for
a written explanation of the whole expression.
~ ~ David
On 3/20/2016 6:00 PM, Petko Yotov wrote:
> You can use a search pattern like this:
> '/^ *"?(The|An?) +/i'
> This assumes that the quote always comes before the rest of the title.
> The question mark after the quote means that there can be zero or one
> quote, like the question mark after the An means that there can be a
> single "n" or none (both artcles A and An will be found).
> In some languages (French) typographical rules may require to have a
> space between the quote and the text, in that case you could have
> '/^ *"? *(The|An?) +/i'
> the asterisk after the space means that there can be zero or more spaces.
> The plus after the last space means that there can be one or more spaces
> after A, An, The.
> In most cases, several regular expressions can be written to match the
> exact same strings.
> The pattern on the cookbook has a tiny optimization but is harder to
> understand for a beginner. In most cases, several regular expressions
> can be written to match the exact same strings, you can have fun. :-)
> On 2016-03-20 21:21, Jake Wartenberg wrote:
>> I suspect this is a pretty basic regex question. I have quotation
>> marks at
>> the beginning of some of my titles, so I modified the TitleNoArticle
>> function from the CustomPagelistSortOrderFunctions Cookbook page:
>> 'preg_replace("/^ *((?:The|An?) |\")/i", "", (@$page["title"] ?
>> $page["title"] : $AsSpacedFunction($name)), 1)';
>> This works great for discarding the leading quotation marks, but I run
>> a problem when I have *both* a leading quotation mark and an article
>> (the/a/an) at the beginning of my title, in which case the page gets
>> alphabetized under the article. I would be really grateful to anyone who
>> could show me how to modify the function to account for this.
> pmwiki-users mailing list
> pmwiki-users at pmichaud.com
More information about the pmwiki-users