How to remove icon from a string?

Hi Experts,

I have a problem to remove icon(s) from a string. I extracted the value from a template and some data contains icon(s). I tried to use regex, yet I couldn’t find the right pattern to capture the right data. Please help!

String: Muhammad12 Daffa Rabbani 345 :cloud: :computer:.pdf

Expected result: Muhammad12 Daffa Rabbani 345.pdf

Thank you!

Hi @D_Okthree ,

Could you let us know how does the String text appear in a Write Line activity ? Could maybe provide a screenshot of the Output Panel after a Write Line is used.

Also, Double click on the output text and check the data present in it.

Hi @supermanPunch ,

This is the result in output panel:

image

image

The reason why I put some digits in the first post sample because we want to allow digits there. Please advice.

@D_Okthree

You can try this gives string output

newoutput=String.Join(" “,stroutput.Trim.Split(” "C).SkipLast(2).ToArray)

You can try this gives Array output

arr_output=stroutput.Trim.Split(" "C).SkipLast(2).ToArray

stroutput is the input

cheers

Hi,

Thanks, but the icon(s) could not be pre-determined and not a normal case. Some data could have it or not and it could come as many as it possible.

@D_Okthree

for that you can try with regular expression

System.text.regularexpressions.regex.match(stringvariable,“[A-Za-z\s]+”).value

Try this if any issue let me know

cheers

Hi @D_Okthree

Use the below regular expression

System.text.regularexpressions.regex.matches(stringvariable,"[\w\d,.\s]+")

Hope it helps!!

Hi,

Do you know how to print result of MatchCollection type?

@D_Okthree

matches gives you the match collection

output=matchesoutput(0)

output=matchesoutput(1)

Have you tried with match which i mentioned above

Hi,

I think it’s working. Thank you!

image

Do you have any reference on any learning material or crash course to generate regex effectively?

1 Like

@D_Okthree ,

Adding on an Alternate with Regex Replace :

Regex :

[^\x20-\x7F]

Debug Panel :
image

Expression :

System.Text.RegularExpressions.Regex.Replace(strText,"[^\x20-\x7F]","")

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