Skip to end of banner
Go to start of banner

matches

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Availability

This routine is available since katl-commons 2.0.3 (for JIRA 5.x) or katl-commons 1.1.10 (for JIRA 4.3.x and 4.4.x) .

Syntax:

matches(string, regex)

Description:

Returns true if character expression string matches the regular expression regex.

Parameters:

Parameter name

Type

Required

Description

string

string

Yes

Specifies a character expression to match the regex against.

regex

string

Yes

Specifies a regular expression to match the specified string.

Return type:

boolean (true/false)

Related routines

Filter by label

There are no items with the selected labels at this time.

Example:

Example 1:

wret = matches("This will return ?", ".*will.*");
print("Return " + wret);

Matches any string containing "will". Prints Return true

Example 2:

wret = matches("This will return ?", "will");
print("Return " + wret);

Matches only the string "will". Prints Return false

Example 3:

wret = matches("This will return ?", ".*will[^\\?]*\\?");
print("Return " + wret);

Matches any string containing "will" and ending with a question mark. Prints Return true

Notes:

  1. As shown in Example 3, use double backslash (\\) instead of a single backslash where needed.
  2. For more information on regular expressions, see http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html

See also:

 

  • No labels