Find and replace functions handle find and replace operations. They cover basic functionality, such as finding the next instance of a search pattern, and complex replacement operations that require no user interaction.

dreamweaver.findNext()

Availability

Dreamweaver 3; modified in Dreamweaver MX 2004.

Description

Finds the next instance of the search string that was specified previously by dreamweaver.setUpFind(), by dreamweaver.setUpComplexFind(), or by the user in the Find dialog box, and selects the instance in the document.

Arguments

{bUseLastSetupSearch}, {document}, {clearSearchResults}

  • The bUseLastSetupSearch argument, which is optional, is a Boolean value. If bUseLastSetupSearch is the value true, which is the default if no argument is given, the function does a find-next operation using the parameters specified by a previous call to either the dreamweaver.setupComplexFind() function or the dreamweaver.setupComplexFindReplace() function. If you set bUseLastSetupSearch to the value false, the function ignores the previously set up search and performs a search for the next instance of the text that is currently selected in the document.

  • The document argument, which is optional, represents the document to be searched.

  • The clearSearchResults argument, which is optional, indicates whether the Find results panel should be cleared before a search operation is performed.

Returns

Nothing.

Enabler

dreamweaver.findAll()

Availability

Dreamweaver 3.

Description

Finds all the instances of the search string that was specified previously by dreamweaver.setUpFind(), by dreamweaver.setUpComplexFind(), or by the user in the Find dialog box, and selects all the instances in the document.

Arguments

The arguments are same as the dreamweaver.findNext() function. See dreamweaver.findNext().

Returns

Nothing.

dreamweaver.replace()

Availability

Dreamweaver 3.

Description

Verifies that the current selection matches the search criteria that was specified by dreamweaver.setUpFindReplace(), by dreamweaver.setUpComplexFindReplace(), or by the user in the Replace dialog box; the function then replaces the selection with the replacement text that is specified by the search request.

Arguments

The arguments are same as the dreamweaver.findNext() function. See dreamweaver.findNext().

Returns

Nothing.

dreamweaver.replaceAll()

Availability

Dreamweaver 3.

Description

Replaces each section of the current document that matches the search criteria that was specified by dreamweaver.setUpFindReplace(), by dreamweaver.setUpComplexFindReplace(), or by the user in the Replace dialog box, with the specified replacement content.

Arguments

The arguments are same as the dreamweaver.findNext() function. See dreamweaver.findNext().

Returns

Nothing.

dreamweaver.setUpComplexFind()

Availability

Dreamweaver 3.

Description

Prepares for an advanced text or tag search by loading the specified XML query.

Arguments

xmlQueryString

  • The xmlQueryString argument is a string of XML code that begins with dwquery and ends with /dwquery. (To get a string of the proper format, set up the query in the Find dialog box, click the Save Query button, open the query file in a text editor, and copy everything from the opening of the dwquery tag to the closing of the /dwquery tag.)

    Note: In a query, certain special characters, such as the backslash character (\), must be escaped. Therefore, to use a backslash in a query, you must write \\.

Returns

Nothing.

Example

The first line of the following example sets up a tag search and specifies that the scope of the search should be the current document. The second line performs the search operation.

 dreamweaver.setUpComplexFind('<dwquery><queryparams matchcase="false" ¬ 
ignorewhitespace="true" useregexp="false"/><find>¬ 
<qtag qname="a"><qattribute qname="href" qcompare="=" qvalue="#">¬ 
    </qattribute><qattribute qname="onMouseOut" qcompare="=" qvalue="" qnegate="true">¬ 
    </qattribute></qtag></find></dwquery>'); 
dw.findNext();

dreamweaver.setUpComplexFindReplace()

Availability

Dreamweaver 3.

Description

Prepares for an advanced text or tag search by loading the specified XML query.

Arguments

xmlQueryString

  • The xmlQueryString argument is a string of XML code that begins with the dwquery tag and ends with the /dwquery tag. (To get a string of the proper format, set up the query in the Find dialog box, click the Save Query button, open the query file in a text editor, and copy everything from the beginning of the dwquery tag to the end of the /dwquery tag.)

    Note: In a query, certain special characters, such as the backslash character (\), must be escaped. Therefore, to use a backslash in a query, you must write \\.

Returns

Nothing.

Example

The first statement in the following example sets up a tag search and specifies that the scope of the search should be four files. The second statement performs the search and replace operation.

 dreamweaver.setUpComplexFindReplace('<dwquery><queryparams ¬ 
matchcase="false" ignorewhitespace="true" useregexp="false"/>¬ 
<find><qtag qname="a"><qattribute qname="href" qcompare="=" qvalue="#">¬ 
</qattribute><qattribute qname="onMouseOut" ¬qcompare="=" qvalue="" qnegate="true">¬ 
</qattribute></qtag></find><replace action="setAttribute" param1="onMouseOut" ¬ 
param2="this.style.color='#000000';this.style.¬ 
fontWeight='normal'"/></dwquery>'); 
dw.replaceAll();

dreamweaver.setUpFind()

Availability

Dreamweaver 3.

Description

Prepares for a text or HTML source search by defining the search parameters for a subsequent dreamweaver.findNext() operation.

Arguments

searchObject

The searchObject argument is an object for which the following properties can be defined:

  • The searchString is the text for which to search.

  • The searchWhat is the location where the search should operate. The possible values are:

    • document - Search in the current active document.

    • allOpenDocuments - Search in all the open documents.

    • site - Search in the current site.

    • selectedFiles - Search in the selected files.

    • selectedText - Search within the selected text or a folder path.

  • The searchSource property is a Boolean value that indicates whether to search the HTML source.

  • The {matchCase} property, which is optional, is a Boolean value that indicates whether the search is case-sensitive. If this property is not explicitly set, it defaults to false.

  • The {matchWholeWord} property, which is optional, is a Boolean value that indicates whether the matches should be whole words.

  • The {ignoreWhitespace} property, which is optional, is a Boolean value that indicates whether white space differences should be ignored. The ignoreWhitespace property defaults to false if the value of the useRegularExpressions property is true, and true if the useRegularExpressions property is false.

  • The {useRegularExpressions} property is a Boolean value that indicates whether the searchString property uses regular expressions. If this property is not explicitly set, it defaults to a value of false.

Returns

Nothing.

dreamweaver.setUpFindReplace()

Availability

Dreamweaver 3.

Description

Prepares for a text or HTML source search by defining the search parameters and the scope for a subsequent dreamweaver.replace() or dreamweaver.replaceAll() operation.

Arguments

searchObject

The searchObject argument is an object for which the following properties can be defined:

  • The searchString property is the text for which to search.

  • The searchWhat is the location where the search should operate. The possible values are:

    • document - Search in the current active document.

    • allOpenDocuments - Search in all the open documents.

    • site - Search in the current site.

    • selectedFiles - Search in the selected files.

    • selectedText - Search within the selected text.

  • The replaceString property is the text with which to replace the selection.

  • The searchSource property is a Boolean value that indicates whether to search the HTML source.

  • The {matchCase} property, which is optional, is a Boolean value that indicates whether the search is case-sensitive. If this property is not explicitly set, it defaults to a false value.

  • The {matchWholeWord} property, which is optional, is a Boolean value that indicates whether the matches should be considered as whole words.

  • The {ignoreWhitespace} property, which is optional, is a Boolean value that indicates whether white space differences should be ignored. The ignoreWhitespace property defaults to false if the useRegularExpressions property has a value of true, and defaults to a value of true if the useRegularExpressions property has a value of false.

  • The {useRegularExpressions} property is a Boolean value that indicates whether the searchString property uses regular expressions. If this property is not explicitly set, it defaults to a value of false.

Returns

Nothing.

dreamweaver.showFindDialog()

Availability

Dreamweaver 3.

Description

Opens the Find dialog box.

Arguments

None.

Returns

Nothing.

Enabler

dreamweaver.showFindReplaceDialog()

Availability

Dreamweaver 3.

Description

Opens the Replace dialog box.

Arguments

None.

Returns

Nothing.

Enabler

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy