androidregexvariablestasker

Remove plus sign from beginning and replace whitespaces of number


I need edit the string variable in Tasker "Variable Search Replace" but dont recognize the special characters.

I need edit below string

+70 888 777 1 1 3
to;
70888777113

How can i achieve this?


Solution

  • You can use the following to match (Easy approach):

    \D               //(any non digit)
    

    And replace with '' (empty string)

    See DEMO

    Code:

    str = str.replaceAll("\\D", "");
    

    Edit: If your string is a part of another string use the following:

    (?<=\d)\s+(?=\d)|\+(?=\d)
    

    See DEMO

    Explanation: