Find and Replace

Top  Previous  Next

 

Introduction

 

Find and Replace is an easy-to-use tool for mass editing texts throughout a questionnaire.

 

Searches on the "Find what" text can be performed by clicking on the "Find Next" button.  Additional clicks will navigate you to the next search result.  The currently selected search result can be automatically replaced with the "Replace with" text by clicking on the "Replace" button.  Alternatively, you can always freely edit the study text currently being viewed.

 

Previously used search criteria for "Find what" and "Replace with" can be accessed using the dropdowns that have been added to those textboxes.

 

The "Replace All" button can be used to quickly replace all matches to the current search criteria.  Before performing the replacement, you will be alerted with a message indicating the number of times the text was found in the questionnaire and that each instance will be replaced with the new text.  If you are not sure you want to make all of these replacements, you may be better off making the replacements one by one using the "Find Next" and "Replace" buttons.

 

The "OK" and "Cancel" buttons can be used to close Find and Replace, either saving or discarding all changes made to the study text.  Saved changes are final.

 

NOTE: For convenience, you can run a search in the Find and Replace window by pressing F3.  Similarly, you can search in the reverse direction by pressing Shift-F3.

 

Search Settings

 

Search settings are available as checkboxes in Find and Replace:

 

"Find previous" reverses the direction in which searches are performed.

"Match case" requires that search results are a case-sensitive match to the search criteria.

"Match whole word" requires that search results match an entire word.  For example, a whole word search for "off" will find "off" and "off-hand", but not "scoff".

"Use wildcards"

"Use regular expressions"

 

What is Searched

 

Most questionnaire fields are searched upon using Find and Replace.   Every text that can be seen by respondents is searched.  Additionally, every text that supports Sawtooth Script is searched.

 

That said, a small number of select fields are not searched.  For example, the names of questions and exercises are not included to prevent an inadvertent change of these fields, which could cause problems in taking the study or in analyzing the data.

 

Use Wildcards

 

When wildcards are enabled, certain characters in the "Find what" text are treated special.  Below are the valid special characters and their meanings:

 

The question mark character "?" matches any one character.  For example, "c?t" will match "cat" and "cot."

The pound character "#" matches any one digit character.

The asterisk character "*" matches any number of any character.  A series of characters do not have to be the same character to match an asterisk.

The at character "@" matches one or more instances of the preceding search token.  For example, "hel@o" will match "hello."

The chevron characters "<" and ">" match the beginning and ending of a word.  For example, "<the>" will not match "then."

The bracket characters "[" and "]" match one character of a set of characters.  For example, "[abc]" can match "a" but not "d."

The exclamation character "!" negates the acceptance of characters appearing between brackets.  For example, "[!abc]" can match "d" but not "a."

The brace characters "{" and "}" define an acceptable quantity of the preceding search token.  Applying a maximum is optional.  For example, "a{2,4}" matches between two and four "a" characters, and "b{3,}" matches three or more "b" characters.

The parentheses characters "(" and ")" group search tokens into a single search token.  This can be used in conjugation with other special characters to achieve more advanced search criteria.  For example, "(ab){2,}" applies the brace character effect to the "ab," causing this search to match text like "abab."

 

Wildcard searches are not compatible with regular expression searches.

 

Though powerful, wildcards come with some limitations.  For increased search criteria flexibility, use regular expressions.

 

Use Regular Expressions

 

When regular expressions are enabled, certain characters in the "Find what" text are treated special.  Below are some of the valid special characters and their meanings:

 

The question mark character "?" matches one or zero instances of the preceding search token.  For example, "hell?o" will match "helo" and "hello."

The plus character "+" matches one or more instances of the preceding search token.  For example, "no+" will match "no" and "noooo," but not "n."

The asterisk character "*" matches zero or more instances of the preceding search token.  For example, "sta*r" will match "str," "star," and "staaar."

The bracket characters "[" and "]" define a set of characters.  For example, "[ab]" can match "a" or "b."

oThe hyphen character "-" inside brackets define a range of characters.  For example, "[a-z0-9]" can match any alphanumeric character.

oThe caret character "^" at the start of a character set negates the valid characters.  For example, "[^aeiou]" can match any non-vowel character.

The period character "." matches almost any single character.  For example, "c.t" can match "cat" and "cot."

oNote that the use of ".", especially ".*", can result in slower or less precise searches.  When possible, it is advised to use character classes with the bracket characters instead.

The brace characters "{" and "}" define a quantity of the preceding search tokens.  For example, "t{2,4}" matches between two and four "t" characters.

oThe maximum can optionally be left blank to not define a maximum.  For example, "[0-9]{3,}" matches a series of at least three numbers.

oLeaving the comma off and having only one value between braces defines an exact valid quantity.  For example, "e{5}" is identical in purpose to "e{5,5}."

The vertical bar character "|" requires that at least one of two search tokens exist.  Vertical bars can be stacked to support three or more valid options.  For example, "hello|hola|bonjour" can match any of three greetings.

The parentheses characters "(" and ")" group search tokens into a single search token.

oParentheses can be used to establish an order of operations on special characters.  For example, "gra|ey" will actually only match "gra" and "ey." You need to use "gr(a|e)y" to match "gray" and "grey."

oParentheses also define capture groups, which can impact replacements.

The backslash character "\" is the escape character.

oThe backslash character proceeded by non-special characters can sometimes have special meanings.  For example, "\d" can match any digit character and "\s" can match any whitespace character.  Similarly, "\D" and "\S" match any non-digit or non-whitespace character, respectively.

oThe backslash character can be used to search for literal versions of the special characters above.  For example, "\?" can match an actual "?" in the text.

oThe backslash character can escape another backslash character.  "\\" matches an actual "\" in the text.

 

Understand that due to the extensive number of special characters supported with regular expressions, not all functionalities available in regular expressions are listed above.  Many freely-available resources can be found online and offer a deeper exploration into regular expressions.

 

When capture groups exist in the search criteria, the Replace and Replace All actions will respect any "$1," "$2," "$3," etc. in the "Replace with" field so long as it corresponds with an equal numbered capture group.  For example, a call to replace "(\d{3}) (\d{4})" with "$2 $1" will replace "123 5678" with "5678 123."

 

Regular expression searches are not compatible with wildcard searches.

 

 

Page link: http://www.sawtoothsoftware.com/help/lighthouse-studio/manual/index.html?find-and-replace.html