Regular Expressions 101

Community Patterns

Match LiveCode Script lines that put message to message box

0

Regular Expression
PCRE (PHP <7.3)

/
^(^\s*\bput\s)((?!\sinto\s).)*$
/
gm

Description

This is intended to be used in LiveCode's ScriptEditor 'Find and Replace' dialog to be able to find all the lines in the stack's scripts where I have put diagnostic comments in scripts that will output the comment to the message box. These take the form of

put "string" [& variable] [ & string]

e.g. put "openCard has completed" put "The document" && tDocumentName && " has loaded."

I need to distinguish lines using "put" to output comments to the message box from the other use of "put" in LiveCode to assign a value to a variable.

e.g. put 10 into tMyNumber put "this is a string" into tMyString

So basically I need to match lines that start with "put" ignoring white space and that don't contain the word "into" in the rest of the line.

The pattern works* in the LiveCode filter command but does not work in the LiveCode Script Editor's Find and Replace dialog.

NOTE: The pattern here misses two edge cases

  • the word 'into' is in the quoted string
  • the word 'into' is in an inline comment

e.g.

put "put the egg into the basket" put "loading data is complete" -- this means all of the data has been loaded into memory.

Submitted by Martin Koob - 4 years ago