Saturday, May 5, 2018

Examples of wildcard characters

Examples of wildcard characters

To locate a specific item when you can't remember exactly how it is spelled, try using a wildcard character in a query.

Wildcards are special characters that can stand in for unknown characters in a text value and are handy for locating multiple items with similar, but not identical data. Wildcards can also help with getting data based on a specified pattern match. For example, finding everyone named John on Park Street.

For more information about queries, see introduction to queries.

Here are some examples of wildcard characters for Access queries:

Character

Description

Example

*

Matches any number of characters. You can use the asterisk (*) anywhere in a character string.

wh* finds what, white, and why, but not awhile or watch.

?

Matches a single alphabet in a specific position.

b?ll finds ball, bell, and bill.

[ ]

Matches characters within the brackets.

b[ae]ll finds ball and bell, but not bill.

!

Excludes characters inside the brackets.

b[!ae]ll finds bill and bull, but not ball or bell.

Like "[!a]*" finds all items that do not begin with the letter a.

-

Matches a range of characters. Remember to specify the characters in ascending order (A to Z, not Z to A).

b[a-c]d finds bad, bbd, and bcd.

#

Matches any single numeric character.

1#3 finds 103, 113, and 123.

Learn more about applying criteria to a query.

Examples of wildcard character pattern matching in expressions

To use a wildcard character within a pattern:

  1. Open your query in Design view.

  2. In the Criteria row of the field that you want to use, type the operator Like in front of your criteria.

  3. Replace one or more characters in the criteria with a wildcard character. For example, Like R?308021 returns RA308021, RB308021, and so on.

  4. On the Design tab, click Run.

Here are some examples of wildcard patterns that you can use in expressions:

C haracter(s)

Use to match

? or _ (underscore)

Any single character

* or %

Zero or more characters

#

Any single digit (0 — 9)

[charlist]

Any single character in charlist

[!charlist]

Any single character not in charlist

[a-zA-Z0-9].

Any alphanumeric character

[A-Z]

Any of the uppercase letters in the range A through Z.

Note:  When you specify a range of characters, the characters must appear in ascending sort. For example, [Z-A] is not a valid pattern.


Take a look at the basics of building an expression.

To match special characters like question mark (?), number sign (#), and asterisk (*), put them in square brackets.

The CHARLIST function gives you matches for one or more characters and can include almost any characters in the ANSI character set, including digits. The CHARLIST is enclosed in brackets ([ ]) and can be used with wildcard characters for more specific matches.

To specify a range of characters, use CHARLIST with a hyphen (-) to separate the upper and lower bounds of the range.

To match the hyphen (-) character, put it at the beginning or end of CHARLIST (after the exclamation mark if you're using one). In any other location, the hyphen identifies a range of ANSI characters.

No comments:

Post a Comment