Main Content

Search & Replace

Find and replace text in Stateflow charts

Description

Use the Search & Replace tool to find and modify text in your Stateflow® charts. Search an individual chart or all of the charts in a Simulink® model. Modify the scope of your search by enabling case-sensitive searching, matching only whole words, using regular expressions to define search patterns, or filtering by object and field types. Enable case-preserving replacements for lowercase, uppercase, title case, or sentence case text.

Stateflow Search and Replace tool

Open the Search & Replace

  • Open a Stateflow chart. Then, in the Modeling tab, select Find > Find & Replace in Chart.

Examples

expand all

  1. In the Search for field, enter the text for which to search.

  2. Modify the scope of your search results.

  3. Click Search. The Search & Replace tool displays the matching text in the center pane of the tool. If the matching text belongs to a graphical object such as a state or transition, the graphical object appears highlighted in the bottom pane of the tool.

    Search and replace tool showing matching text in a state label.

  4. To highlight to the object in the Stateflow Editor, double-click the bottom pane.

  5. To find the next match, click Search again.

  1. Search for the text to replace, as described in Search for Text.

  2. In the Replace with field, enter the text with which to replace the text found by your search.

  3. To enable case-preserving replacements, select Preserve case.

  4. Click one of these buttons:

    • Search — Skip the current search result and search for the next match.

    • Replace — Replace the current search result with the replacement text and search for the next match.

    • Replace all — Replace all instances that match the search text. Replacement spans from the current search result to the end of the current Stateflow chart. The Search & Replace tool ignores any matches that you previously skipped by clicking the Search button.

    • Replace all in this object — Replace all instances that match the search text in the current Stateflow object. The Search & Replace tool replaces any matches that you previously skipped by clicking the Search button.

Parameters

expand all

Select this parameter to enable case-sensitive searching.

  • When you select this parameter, the Search & Replace tool finds only text that exactly matches the text in the Search for field.

  • When you clear this parameter, the Search & Replace tool matches the character sequence in the Search for field, regardless of case. For example, the search text "gear" matches the text "gear", "Gear", or "GEAR".

Select this parameter to enable case-preserving replacements. When you select this parameter, the Search & Replace tool replaces the matching text based on these conditions:

  • If the matching text has only lowercase characters, the Search & Replace tool replaces the matching text entirely with the lowercase equivalent of all replacement characters. For example, if the replacement text is "AnDreW", the matching text "james" is replaced by "andrew".

  • If the matching text has only uppercase characters, the Search & Replace tool replaces the matching text entirely with the uppercase equivalent of all replacement characters. For example, if the replacement text is "AnDreW", the matching text "JAMES" is replaced by "ANDREW".

  • If the matching text uses title case, with uppercase characters in the first character position of each word, the Search & Replace tool replaces the matching text with the replacement text in title case. For example, if the replacement text is "AnDreW jAcksOn", the matching text "James Monroe" is replaced by "Andrew Jackson".

  • If the matching text uses sentence case, with an uppercase character in the first character position of a sentence and all other sentence characters in lowercase, the Search & Replace tool replaces the matching text with the replacement text in sentence case. For example, if the replacement text is "AnDreW is TALL", the matching text "James is tall" is replaced by "Andrew is tall".

If the matching text does not follow any of these patterns, the Search & Replace tool replaces the matching text using the exact case specified by the replacement text.

Specify the location to search. You can select an individual chart or all of the charts in a loaded Simulink model. By default, the Search & Replace tool searches only the chart in which you opened the tool.

Note

The left drop-down list shows the charts in only one model at a time. To select a Stateflow chart in a different model, first select the model. Then open the drop-down list a second time and select the chart.

Use the drop-down list to the right of the Search in parameter to specify one of these options:

  • Contains word — Search for text in any expression. For example, the search text "gear" matches the text "gear_state".

  • Match whole word — Search for whole word expressions delimited by a blank space or a character that is not alphanumeric or an underscore character. For example, the search text "gear" does not match the text "gear_state".

  • Regular expression — Treat the search text as a regular expression. For example,the search text "g\w*_" matches any text that begins with the letter g and ends with an underscore. For more information, see Regular Expressions.

Specify the type of objects in which to search. You can limit your search to the Stateflow machine, charts, states, junctions, transitions, data, events, and messages. For more information, see Overview of Stateflow Objects.

Specify the type of fields in which to search. You can limit your search to names, labels, descriptions, and document links.

Note

The Search & Replace tool looks for matching text anywhere in a state label regardless of whether you limit your search to names or labels.

Tips

  • The Search & Replace tool does not search the names of Simulink models and Stateflow charts. To change the names of models and charts, use the Simulink model window.

Version History

Introduced before R2006a