Regex (matchChunk) help...

Jim Lambert jiml at
Fri Jun 15 21:06:04 EDT 2018

Building on what Mark Wieder elegantly wrote:

> MarkW wrote:
>  filter lotsOfText with "*selkirkst*skyrider1*”

function extractStrings lotsOfText, startWord, endWord

	replace cr with space in lotsOfText -- Makes sure lotsOfText is just a single line

	replace startWord with cr & startWord in lotsOfText -- Makes sure a line starts with the startWord

	replace endWord with endWord & cr in lotsOfText -- Makes sure a line ends with the endWord

	filter lotsOfText with "*" & startWord & "*" & endWord  — Mark’s suggestion

	return lotsOfText

end extractStrings

Try it with your original gibberish. I‘ve added a second instance of the string you want to extract to show that the function will return all instances.

Use the *selkirkst* function to check whether a *string* contains a

specified pattern. If *selkirkst* includes a pair of parentheses, the

position of the substring matching the part of theregular expression inside

the parentheses is placed in the variables in the *positionVarsList*. The

number of the first character in the matching substring is placed in the

first variable in the positionVarsList, and the number of the last

*selkirkst is

placed in the second **skyrider1*. Additional starting and ending

positions, matching additional parenthetical expressions, are placed in

additional pairs of variables in thepositionVarsList. If the

*selkirkst* function

returns false, the values of the variables in the positionVarsListare not

*selkirkst is

placed in the third **skyrider1*. changed. The string and regularExpression are always case-sensitive,

regardless of the setting of the caseSensitive property. (If you need to

make a case-insensitive comparison, use "(?i)" at the start of the

regularExpression to make the match case-insensitive.)

Jim Lambert

More information about the Use-livecode mailing list