like() Function

Function

like( stringA, stringB )

Tests whether a string of text is like a given pattern.

Parameters

Keyword Type Description

stringA

text string

Text to match

stringB

text string

List the characters to match.

Returns

Boolean

Usage considerations

Using wildcards

stringB accepts the following wildcard characters:

  • * - matches one or more characters (including an empty character). Multiple consecutive asterisks (multiple anything) is invalid input; use just one.
  • ? - matches any one character. Multiple question marks match the same number of characters.
  • [characters] - matches one of the enclosed characters.
  • [^characters] - matches anything but the enclosed characters.
  • [number-number] - matches a range of numbers created in combination with the enclosed.

Wildcard examples

  • b*t matches bet; beat; and beast.
  • b?t matches bat ; and bet; and bit.

  • a[cr]t matches act and art.
  • ab[^bc] matches abd but not abb nor abc.
  • [0-2]4 matches 04 and 14 and 24 not 74.

Examples

You can experiment with this function in the test box below.

Test Input

like("brian","*ian") returns true

Open in Github Built: Fri, Oct 22, 2021 (11:09:30 AM)

On This Page

FEEDBACK