Stateflow    

Using Different Search Types

Enter search pattern text in the Search for text box. You can use one of the following settings in the Match options field (unlabeled and just to the right of the Search in field) to further refine the meaning of the text entered.

Contains word

Select this option to specify that the search pattern text is a whole word expression used in a Stateflow chart with no specific beginning and end delimiters. In other words, find the specified text in any setting.

The following example is taken from the Sensor Failure Detection demo model.

Searching for the string fail with the Contains word option set finds both occurrences of the string fail.

Match case (Case Sensitive)

By selecting the Match case option, you enable case-sensitive searching. In this case, the Search & Replace tool finds only text matching the search pattern exactly.

By clearing the Match case option, you enable case-insensitive searching. In this case, search pattern characters entered in lower- or uppercase find matching text strings with the same sequence of base characters in lower- or uppercase. For example, the search string "AnDrEw" finds the matching text "andrew" or "Andrew" or "ANDREW".

Match whole word

Select this option to specify that the search pattern text in the Search for field is a whole word expression used in a Stateflow chart with beginning and end delimiters consisting of a blank space or a character that is not alphanumeric and not an underscore character (_).

In the preceding example from the Sensor Failure Detection demo model, if Match whole word is selected, searching for the string fail finds no text within the above state. However, searching for the string "fail_state" does find the text "fail_state" as part of the second line since it is delimited as a word by a space on the front and a left square bracket ([) on the back.

Regular expression

Set the Match options field to Regular expression to search for text that varies from character to character within defined limits.

A regular expression is a string composed of letters, numbers, and special symbols that defines one or more string candidates. Some characters have special meaning when used in a regular expression, while other characters are interpreted as themselves. Any other character appearing in a regular expression is ordinary, unless a backslash (\) character precedes it.

If the Match options field is set to Regular expression in the preceding example from the Sensor Failure Detection demo model, searching for the string "fail_" matches the "fail_" string that is part of the second line, character for character. Searching with the regular expression "\w*_" also finds the string "fail_". This search string uses the regular expression shorthand "\w" that represents any part-of-word character, an asterisk (*), which represents any number of any characters, and an underscore (_), which represents itself.

For a list of regular expression metacharacters, see the topic Regular Expressions in MATLAB documentation.

Searching with Regular Expression Tokens

Within a regular expression, you use parentheses to group characters or expressions. For example, the regular expression "and(y|rew)" matches the text "andy" or "andrew". Parentheses also have the side effect of remembering what they match so that you can recall and reuse the found text with a special variable in the Search for field. These are referred to as tokens.

For an understanding of how to use tokens to enhance searching in the Search & Replace tool, see the topic Searching with Tokens in MATLAB documentation.

You can also use tokens in the Replace with field. See Replacing with Tokens in for a description of using regular expression tokens for replacing.

Preserve case

This option actually modifies replacement text and not search text. For an understanding of this option, see Replacing with Case Preservation.


  Opening the Search & Replace Tool Specify the Search Scope