http: grep syntax for use in Tex-Edit
http: grep syntax for use in Tex-Edit
- Subject: http: grep syntax for use in Tex-Edit
- From: Matt Petrowsky <email@hidden>
- Date: Tue, 6 May 2003 22:28:40 -0700
Just wondering if anyone has any regex code for pulling out http://
links (or ftp://, etc.) and formatting them as href tags within
Tex-Edit Plus.
I know there's code out there somewhere and parsing through the grep
for breaking down a URI
^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?
provided from
http://www.ietf.org/rfc/rfc2396.txt is a great starting
point but doesn't seem to work natively.
Just thought I would ask before I start heading into the long haul
trying to account for urls ending with "." or "\r".
Here's my far from completed code so far. It uses Tex-Edits wildcard
run right now. But I would like to switch to grep since it would be
more precise.
--- snip ---
-- Basic routine for swapping characters or works out.
on swapIt(input, output)
repeat with i from 1 to count of input
tell window 1 of application "Tex-Edit Plus"
replace looking for item i of input replacing with item i of output
with cases matching
end tell
end repeat
end swapIt
tell window 1 of application "Tex-Edit Plus"
-- format all urls
set urlEnd to {".html.", ".htm.", ".php.", ".shtml.", ".html" &
return, ".htm" & return, ".php" & return, ".shtml" & return}
set urlNice to {".html .", ".htm .", ".php .", ".shtml .", ".html " &
return, ".htm " & return, ".php " & return, ".shtml " & return}
my swapIt(urlEnd, urlNice)
replace looking for "
http://^* " replacing with "<a href=\"^*\">^*</a>"
replace looking for " \">" replacing with "\">"
replace looking for " </a>" replacing with "</a>"
replace looking for "< <a" replacing with "<<a"
end tell
--- snip ---
Matt Petrowsky
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.