Legacy Dev Forum Posts

 View Only

Sign Up

  • 1.  REGEX Formatting

    Posted 06-05-2025 19:19

    masanchezmemo | 2018-01-30 02:03:13 UTC | #1

    Hey guys!!!

    I need a bit of advice. When receiving an incoming call the ANI I get is for example 0995060851 and I need to format the string to +593995060851;and, for outbound call I need the oposite, I mean from a string +593995060851 I have to convert to a dial string like this 0995060851.

    I'm new with regex and trying to learn.

    Tks,

    Mario


    Ullyot_Jim | 2018-01-30 04:02:07 UTC | #2

    Hi Mario,

    Is this within an Architect call flow?

    If so, we have a phone number data type which might help. Here is a link to it:

    https://help.mypurecloud.com/articles/about-the-phone-number-data-type/

    Here is an expression example that shows extracting the subscriber number:

    ToPhoneNumber("+593995060851").subscriberNumber return "995060851"

    or if you wanted the dialing code:

    ToPhoneNumber("+593995060851").dialingCode would return "593"

    I did try submitting "0995060851" to ToPhoneNumber and it did not identify a dialing code.

    Or maybe you're looking to do straight string manipulation? If so, Architect has Left, Right and Substring functions to extract parts of strings along with a Length function.

    Right("Hello", 3) would return the string value "llo" Left("Hello", 2) would return the string value "He" Substring("Hello", 1, 3) would return the string value "ell" Length("Hello") would return the integer value 5

    And of course you can use variables to supply the string value to submit to those functions.

    Left(Append(Task.MyString, "ts"), 5) where Task.MyString = "tes" would return "test"

    Remember when working with parameter values passed to functions that Architect's expression help will let you know if a NOTSET value is valid or not for a parameter. In your expression you can test for NOTSET by using the IsSet function. Here is an example that checks for a NOT_SET string value and returns the string "default" if it is. Otherwise it would return the rightmost 5 characters of the string value contained in Task.MyString:

    If(IsSet(Task.MyString), Right(Task.MyString, 5), "default")

    There is a lot more in Architect's expression help including example function usage and outputs.

    Hope this helps,

    Jim


    masanchezmemo | 2018-01-30 11:17:32 UTC | #3

    Hey Jim,

    Thanks a lot for your response. I forgot to mention that I was trying to define a new Number Plan under Telephony - Sites.

    Tks,

    Mario


    system | 2018-03-02 11:27:10 UTC | #4

    This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.


    This post was migrated from the old Developer Forum.

    ref: 2423