Replace part of a text by asterisks

Hi, Koders

How can i replace most part of an email or phone number by asterisks folowing this example:

[email protected]
m***************@k******.com

and

(99) 99999-9999
(99) *****-9999

Since now i apreciate

there might be a regex, which is able to do this…

alternatively do it manually step by step

  1. split the email address by @ to get a list
  2. select the first item from the list to get myappfromkodular, also select the 2nd item from the list to get kodular.com
  3. split the second part by . to get a list
  4. select the first item from the list to get kodular

prepare a procedure, which returns n asterisks

for myappfromkodular and kodular to the following

  1. get the length of the string
  2. keep the first character of the string and add the asterisks using the previously mentioned procedure
  3. put the strings back together

do it similarly for the phone number

Taifun

1 Like