Phone Number (%PHONE) Macro

Applies to ReadyAPI 3.10, last modified on October 07, 2021

The Phone Number macro is used to insert phone numbers into the strings generated by a data source using the Custom String data generator.

The macro is an analog of the Phone Number data generator.

Syntax

The macro is specified using the following regular expression:

%PHONE(NumberFormat)

Parameters

NumberFormat

Specifies a format for the generated phone numbers. The default value of the parameter is XXX-XXX-XXXX.

You can specify any sting. The X character will transform to a random single digit. Other symbols will not transform and will be represented as they are.

ReadyAPI considers the percent ("%") and closing parenthesis symbols as service symbols, so avoid using them when specifying the parameter. Otherwise, it causes errors.

Examples

The following example demonstrates how to use the Phone Number macro:

  • tel:+1-%PHONE(XXX-XXX-XXXX)
    Example: Phone Number macro in Data Generator

    Click the image to enlarge it.

    Generates a URI to a phone number in the United States.

  • %PHONE(+X XXX-XXX-XXXX)

    Generates phone numbers that start with +.

  • %PHONE(55X-XXX-XXXX)

    Generates phone numbers that start with 55.

  • %PHONE(xxx-xxx-xxxx)

    The parameter is case-sensitive, so the x symbols will not be transformed to digits. This macro generates the xxx-xxx-xxxx string.

Remarks

For more information on adding macros to custom strings, see About Custom String Generator.

For more information on general rules used for specifying macro parameters, see Custom String Generator Rules.

See Also

Phone Number Generator
Custom String Generator
Macro Reference

Highlight search results