Phone Number (%PHONE) Macro

Applies to ReadyAPI 3.53, last modified on May 15, 2024

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.


The macro is specified using the following regular expression:




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.


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.


    Generates phone numbers that start with +.


    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.


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