Words containing "the" substring: Difference between revisions

Content added Content deleted
m (→‎{{header|AppleScript}}: Minor preamble edit.)
m (→‎{{header|AppleScript}}: Minor comment edits.)
Line 129: Line 129:
<lang applescript>on wordsContaining(textFile, searchText, minLength)
<lang applescript>on wordsContaining(textFile, searchText, minLength)
-- Set up and execute a shell script which uses grep to find words containing the search text
-- Set up and execute a shell script which uses grep to find words containing the search text
-- (matching the current AppleScript case-sensitivity setting) and awk to pass those which
-- (matching AppleScript's current case-sensitivity setting) and awk to pass those which
-- satisfy the minumum length requirement.
-- satisfy the minimum length requirement.
if ("A" = "a") then
if ("A" = "a") then
set part1 to "grep -io "
set part1 to "grep -io "
Line 157: Line 157:
set theWords to theText's componentsSeparatedByString:(linefeed)
set theWords to theText's componentsSeparatedByString:(linefeed)
-- Filter the resulting array for strings which meet the search text and minimum length requirements,
-- Filter the resulting array for strings which meet the search text and minimum length requirements,
-- matching the current AppleScript case-sensitivity setting. NSString lengths are measured in 16-bit
-- matching AppleScript's current case-sensitivity setting. NSString lengths are measured in 16-bit
-- code units so use regex to check the lengths in characters.
-- code units so use regex to check the lengths in characters.
if ("A" = "a") then
if ("A" = "a") then