Find and Replace

Each of Enterprise Architect's code editors facilitates searching for and replacing terms in the editor, through the Find and Replace dialog.

Access

Highlight the required text string and press:

•

( Ctrl+F ) for the find controls only, or

•

( Ctrl+R ) for both find and replace controls

In each instance, the Find what field is populated with the text currently selected in the editor. If no text is selected in the editor, the Find what field is populated with the word at the current cursor position. If no word exists at the current cursor position, the last searched-for term is used.

Basic Operations:

Commands:

Command

Action

See also

Find Next

Locate and highlight the next instance (relative to the current cursor position) of the text specified in the Find what field.

Replace

Replace the current instance of the text specified in the Find what field with the text specified in the Replace with field, and then locate and highlight the next instance (relative to the current cursor position) of the text specified in the Find what field.

Replace All

Automatically replace all instances of the text specified in the Find what field with the text specified in the Replace with field.

Options:

Option

Action

See also

Match Case

Specify that the case of each character in the text string in the Find what field is significant when searching for matches in the code.

Match whole word

Specify that the text string in the Find what field is a complete word and should not be matched with instances of the text that form part of a longer string.

For example, searches for ARE should not match those letters in instances of the words AREA or ARENA.

Search up

Perform the search from the current cursor position up to the start of the file, rather than in the default direction of current cursor position to end of file.

Use Regular Expressions

Evaluate specific character sequences in the Find what and Replace with fields as Regular Expressions (see below).

Topics

Topic

Detail

See also

Regular Expressions

A Regular Expression is a formal definition of a search pattern, which can be used to match specific characters, words or patterns of characters.

For the sake of simplicity, the Code Editor's 'find and replace' mechanism supports only a subset of the standard Regular Expression grammar.

Text in the Find what and Replace with fields is only interpreted as a Regular Expression if the Use Regular Expressions checkbox is selected in the Find and Replace dialog.

Meta sequences

If the Use Regular Expressions checkbox is selected, most characters in the Find what field are treated as literals (that is, they match only themselves).

The exceptions are called metasequences; each metasequence recognized in the Code Editor Find and Replace dialog is described in the following table:

Metasequence

Description

.

Represents any single character.

For example: .at is matched to cat, hat, bat and rat.

\<

Indicates that the text is the start of a word.

For example: \<cat is matched to catastrophe and cataclysm, but not concatenate.

\>

Indicates that the text is the end of a word.

For example: hat\> is matched to that and chat, but not hate.

( ... )

Indicates alternative single characters that can be matched. The characters can be specific - ( chr ) - or in an alphabetical or numerical range - ( a-m ).

For example: ( hc ) at is matched to hat and cat but not bat.

For example: ( a-m ) Class is matched to any name in the range aClass - mClass.

( ^... )

Indicates alternative single characters that should be excluded from a match. The characters can be specific - ( ^chr ) - or in an alphabetical or numerical range - ( ^a-m ).

For example: ( ^hc ) at is matched to rat and bat but hat and cat are excluded.

For example: ( ^a-m ) Class is matched to any name in the range nClass to zClass but aClass to mClass are excluded.

For example: b( ea ) +t is matched to bet, bat, beat, beet and baat but not bt.

If a single character metasequence is preceded by a backslash (\) it is treated as a literal characterc\( at\ ) matches c( at ) as the brackets are treated literally.

When the Use Regular Expressions checkbox is selected, a metasequence helper menu is available to the right of both of the Find what and Replacewith fields; selecting a metasequence from this menu inserts the metasequence into the field, replacing or wrapping the currently selected text as appropriate.

Tagged Regions

When 'find and replacing' with Regular Expressions, up to nine sections of the original term can be substituted into the replacement term.

The metasequences \( and \) denote the start and the end of a tagged region; the section of the matched text that falls within the tagged region can be included in the replacement text with the metasequence \n (where n is the tagged region number between 1 and 9).

For example:

Find what: \(( A-Za-z ) +\)'s things

Replace with items that belong to \1

Original text: These are all Michael's things.Replaced text: These are all items that belong to Michael

The material ("material" includes all pages, documents and on-line graphics) on this web site is protected by copyright law. (C) 1998-2013 Sparx Systems Pty Ltd.