ReGex Format a phone Number

Hi all I could use some help on a script much like the following post found HERE

However, I need to be able to extract the phone number “310-555-1234” or just “3105551234” either option will work whatever is easier from this text:

tel:+1-310-555-1234

I greatly appreciate the help!

Is this string always the same? If so, removing just the first four chars would work, or?

{
      "Command": "sourceExtract",
      "Target": "regex=tel:\\+([A-Za-z0-9]+(-[A-Za-z0-9]+)+)",
      "Value": "Phone",
      "Description": ""
    }

do I place the {PhoneNumber} between the \

regex=tel:{PhoneNumber} +([A-Za-z0-9]+(-[A-Za-z0-9]+)+)",

Yes basically the format is the same every time I just need to remove the following"

tel:+1-

so that all I have left for the phone number is 310-555-1234

just try the code as it is

@uiuser lol, i must have been exhausted when I wrote my last response! I just realized it was for the source code dirrrr!!

That being said the issue I am now facing is that the code cannot be extracted from source as it is from a pop-up that is not being found with the source search…

I am able to grab the phone number and just need to remove the following:

tel:-1-

so that my final value is

310-555-1234

I assumed you are extracting value in variable Phone

{
      "Command": "executeScript",
      "Target": "return ${Phone}.replace(\"tel:-1-\",\"\");",
      "Value": "Phone",
      "Description": ""
    }

@uiuser

You are the best I should know this I just found the command guide! What really messed me up, though is the changes made from the old school version of ui.vision to now and then Chrome making changes over the years! Your help is appreciated!

Now I just need to figure out how to obtain a date when it’s not found in the source code and when we have users using both Macs and Windows OS…

@uiuser The script is not allowed by Chrome ‘imsafe=eval’ error… So I tried executeScript_Sandbox

      "Target": "return ${Phone}.replace(\"tel:-1-\",\"\");",

However, it keeps kicking back “Invalid or unexpected token”

I believe the \ \ are causing the error… Any input?

its working fine here on chrome

try other browser

 {
      "Command": "store",
      "Target": "tel:+1-310-555-1234",
      "Value": "Phone",
      "Description": ""
    },
    {
      "Command": "executeScript",
      "Target": "return ${Phone}.replace(\"tel:+1-\",\"\");",
      "Value": "Phone",
      "Description": ""
    }