Link Pattern



Sister

We consider two or more capitalized words run together to be a potential hyperlink. For this purpose a word must be all alphabetic and have at least one lower-case letter.

  $linkWord = "[A-Z][a-z]+";

# require 5.004; # use locale; # $lc = join '', grep { uc($_) ne $_ } map { chr($_) } 1..255; # $uc = join '', grep { lc($_) ne $_ } map { chr($_) } 1..255; # $linkWord = "[$uc][$lc]+";

$LinkPattern = "($linkWord){2,}";

Some people might find this overly restrictive, especially people named O'Connor. The rule does require ingenuity at times, but, it is at least easy to articulate and remember.

Can I suggest replacing the pattern with "[A-Z-][a-z-]+" to handle european languages? I might also work on a french version of the code if anybody else shows interest. MarcAntoineParent.

Diacritical support added. --DaveSmith


Extending the link pattern to allow for optional trailing number is trivially easy, and allows links like MoreDiscussion1, MoreDiscussion2, etc. It also allows for links like DayNotes19991210, which opens up possibilities for having calendar pages with DateStamps.

$LinkPattern = "($linkWord){2,}(\d*)";

--DaveSmith


Has there been any abuse or crashes caused by placing no limit on the number of words in the LinkPattern? Perhaps
{2,}
should at least be brought down to
{2,200}
Yow, that changed the code folks get with the download. I had no idea we were messing with LiveCode --ChrisGarrod

 

Last edited January 22, 2002
Return to WelcomeVisitors