[pmwiki-users] Release: GoogleMapsInterface

Craige Leeder craige at internetadvisor.ca
Wed Dec 6 15:21:45 CST 2006


Patrick R. Michaud wrote:

>The difference between .* and .*? is that .*? matches the shortest
>string possible, while .* matches the longest string possible.
>
>So, for example, if we use .* instead of .*?, as in:
>
>    Markup('map', '_begin', 
>      '/\\(:map(-location|-end)?(\\s.*)?:\\)/ie',    
>      "CvtMarkup('$1', PSS('$2'))");
>
>and someone writes a markup line like
>
>    (:map abc:) (:comment def:)
>
>then the pattern for (:map:) inadvertently ends up matching both 
>directives, with $2 set to "abc:) (:comment def".  Using .*? 
>means that we stop at the first colon+paren that we find, while
>using .* means that we'll stop at the last colon+paren that we 
>find.
>  
>
Okay. That's something I didn't know.

>...snd we want the question mark at the end of (\\s.*?)?  because
>the space is required only if there are any arguments.  Without
>that question mark, we can't match (:map:), (:map-location:), or 
>(:map-end:).
>
>Lastly, it's probably worth pointing out that all of PmWiki's
>core directives use "end" without a hyphen, as in (:ifend:), 
>(:tableend:), (:markupend:), (:divend:), etc.  To avoid confusion
>among authors, you might want to follow (or at least allow) the same 
>convention for (:mapend:):
>
>    Markup('map', '_begin', 
>      '/\\(:map(-location|-?end)?(\\s.*?)?:\\)/ie',    
>      "CvtMarkup('$1', PSS('$2'))");
>  
>

Okay, I made it made it manditory. I was going to make it optional, but 
it didn't seem like a good idea. (:mapend:) looks like it should end 
map, and (:map-end:) looks like it should modify (:map:), as 
(:map-location:) does. I will save the '-(.*?) for such a thing.

- Craige
-- InternetAdvisor.ca




More information about the pmwiki-users mailing list