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.
![](tool-search-and-replace.png)
Open the Search & Replace
Open a Stateflow chart. Then, in the Modeling tab, select Find > Find & Replace in Chart.
Examples
Search for Text
In the Search for field, enter the text for which to search.
Modify the scope of your search results.
To enable case-sensitive searching, select Match case.
To specify the chart or model in which to search, use the Search in drop-down list.
To match only whole words or to define a search pattern by using a regular expression, use the drop-down list to the right of Search in.
To filter your search targets by object and field type, select one or more check boxes under Object types or Field types.
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.
To highlight to the object in the Stateflow Editor, double-click the bottom pane.
To find the next match, click Search again.
Replace Text
Search for the text to replace, as described in Search for Text.
In the Replace with field, enter the text with which to replace the text found by your search.
To enable case-preserving replacements, select Preserve case.
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
Match case
— Case-sensitive searching
off
(default) | on
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"
.
Preserve case
— Case-preserving replacement
off
(default) | on
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.
Search in
— Location to search
chart name (default) | model name
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.
Style
— Style of text for which to search
Contains word
(default) | Match whole word
| Regular expression
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 letterg
and ends with an underscore. For more information, see Regular Expressions.
Object types
— Type of objects in which to search
Machine
| Charts
| States
Junctions
| Transitions
| Data
| Events
| Messages
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.
Field types
— Type of fields in which to search
Names
| Labels
| Descriptions
| Document links
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
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)