Use regular expressions in qtp

Source: Internet
Author: User
Regexp object

  Attribute:

Global attributes:

Sets or returns a Boolean value that specifies whether the entire search string matches all or only the first one.

Ignorecase attributes:

Sets or returns a Boolean value to indicate whether the mode search is case sensitive.

Pattern attributes:

Set or return the regular expression pattern to be searched.

 Method:

  • Execute method:

Perform regular expression search on the specified string.

Object. Execute (string)

Parameters:

Object: required. It is always the name of a Regexp object.

String: required. The text string on which the regular expression is to be executed.

Note:

The regular expression search design mode is set through the pattern of the Regexp object.

The execute method returns a matches set, which contains each matching match object found in the string. If no match is found, execute returns an empty matches set.

  • Replace method:

Replace the text found in the regular expression search.

Object. Replace (string1, string2)

Parameters:

Object: required. It is always the name of a Regexp object.

String1: required. String1 is the string to be replaced by text.

String2: required. String2 is a replacement text string.

Note:

The actual mode of the replaced text is set through the pattern attribute of the Regexp object.

The replace method returns a copy of string1, where the Regexp. Pattern text has been replaced with string2. If no matching text is found, the original copy of string1 is returned.

  • Test method:

Perform a regular expression search on the specified string and return a Boolean value indicating whether the matching mode is found.

Object. Test (string)

Parameters:

Object: required. It is always the name of a Regexp object.

String: required. The text string to be searched by the regular expression.

Note:

The actual pattern of Regular Expression search is set through the pattern attribute of the Regexp object. The Regexp. Global attribute has no effect on the test method.

If the matching mode is found, the test method returns true; otherwise, false.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: [email protected] and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.