Regular expression task

Hi All

I’m having 2 scenarios
Scenario 1
Input: 999-999-999
Output: xxx-xxx-999
Input: 9999999999
Output: XXXXX9999

Scenario2
Input: 999-999-999
Output: xxxxxx-999
Input: 9999999999
Output: XXXXX9999

(Inputs can be alpha numeric , value and size can be also changed)

1 Like

Check this post

1 Like

To handle both the scenario together
Use this expression which is combined of both Regex that was shared earlier
In assign activity like this

str_output = IF(str_input.ToString.Contains(β€œ-β€œ), String.Join(β€œ-”,Split(strinput.ToString,β€œ-”).Take(2).AsEnumerable().select(Function(a) System.Text.RegularExpressions.Regex.Replace(a.ToString,β€œ(\w)”,β€œx”)).ToArray()).ToString+β€œ-”+Split(strinput,β€œ-”).Last.ToString,
System.Text.RegularExpressions.Regex.Replace(str_input.ToString,”[1]{4}”,”****”).ToString)

Cheers @emm


  1. 0-9 β†©οΈŽ

thanks for replying…to do seperate these scenarios what to do

for separate scenarios
here you go two expressions
–for one with - in the string
str_input.ToString.Contains(β€œ-β€œ), String.Join(β€œ-”,Split(strinput.ToString,β€œ-”).Take(2).AsEnumerable().select(Function(a) System.Text.RegularExpressions.Regex.Replace(a.ToString,β€œ(\w)”,β€œx”)).ToArray()).ToString+β€œ-”+Split(strinput,β€œ-”).Last.ToString

–for one without - in the string
System.Text.RegularExpressions.Regex.Replace(str_input.ToString,”[1]{4}”,”****”).ToString

Cheers @emm


  1. 0-9 β†©οΈŽ