<div dir="ltr">This works great.  Thanks, Petko.</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 21, 2016 at 1:45 AM, Petko Yotov <span dir="ltr"><<a href="mailto:5ko@5ko.fr" target="_blank">5ko@5ko.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The previous patterns didn't capture a quote that precedes words other than The/A/An. Here is another pattern:<br>
<br>
  '/^ *((The|An?) +|")+/i'<br>
or<br>
  '/^ *(The +|An? +|")+/i'<br>
<br>
It looks like yours, but adds a plus after the parentheses, meaning that the things in the parentheses can appear once or more times.<br>
<br>
Alternatively, if the pattern becomes or feels too complex, you can separate it in different patterns that will be replaced one after another. In this case place the two patterns in array(...):<br>
<br>
  $FmtPV['$TitleNoArticle'] =<br>
    'preg_replace(array("/^ *\"/", "/^ *(?:The|An?) /i"), "", (@$page["title"] ? $page["title"] : $AsSpacedFunction($name)), 1)';<br>
<br>
Wow that actually looks more complex than the combined pattern! :-)<span class="HOEnZb"><font color="#888888"><br>
<br>
Petko</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
On 2016-03-20 23:00, Petko Yotov wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
You can use a search pattern like this:<br>
<br>
  '/^ *"?(The|An?) +/i'<br>
<br>
This assumes that the quote always comes before the rest of the title.<br>
<br>
The question mark after the quote means that there can be zero or one<br>
quote, like the question mark after the An means that there can be a<br>
single "n" or none (both artcles A and An will be found).<br>
<br>
In some languages (French) typographical rules may require to have a<br>
space between the quote and the text, in that case you could have<br>
<br>
  '/^ *"? *(The|An?) +/i'<br>
<br>
the asterisk after the space means that there can be zero or more spaces.<br>
<br>
The plus after the last space means that there can be one or more<br>
spaces after A, An, The.<br>
<br>
In most cases, several regular expressions can be written to match the<br>
exact same strings.<br>
<br>
The pattern on the cookbook has a tiny optimization but is harder to<br>
understand for a beginner. In most cases, several regular expressions<br>
can be written to match the exact same strings, you can have fun. :-)<br>
<br>
Petko<br>
<br>
On 2016-03-20 21:21, Jake Wartenberg wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I suspect this is a pretty basic regex question.  I have quotation marks at<br>
the beginning of some of my titles, so I modified the TitleNoArticle<br>
function from the CustomPagelistSortOrderFunctions Cookbook page:<br>
<br>
'preg_replace("/^ *((?:The|An?) |\")/i", "", (@$page["title"] ?<br>
$page["title"] : $AsSpacedFunction($name)), 1)';<br>
<br>
This works great for discarding the leading quotation marks, but I run into<br>
a problem when I have *both* a leading quotation mark and an article<br>
(the/a/an) at the beginning of my title, in which case the page gets<br>
alphabetized under the article.  I would be really grateful to anyone who<br>
could show me how to modify the function to account for this.<br>
</blockquote></blockquote>
<br>
_______________________________________________<br>
pmwiki-users mailing list<br>
<a href="mailto:pmwiki-users@pmichaud.com" target="_blank">pmwiki-users@pmichaud.com</a><br>
<a href="http://www.pmichaud.com/mailman/listinfo/pmwiki-users" rel="noreferrer" target="_blank">http://www.pmichaud.com/mailman/listinfo/pmwiki-users</a><br>
</div></div></blockquote></div><br></div>