Regex TEXT Body-help

Hi everyone can I get assistance please: I am reading an outlook email body:
This is the normal email before I use regex:

Then after regex-it’s suppose to close all the spaces since I do not want any spaces but it does not it still the same as the above after I had used the regex see what I am using:

‘APIEmail_body’ as the original outlook body want to change and close spaces on

Hi @Anelisa_Bolosha1

Try this

StringBody = System.Text.RegularExpressions.Regex.Replace(APIEmail_body, "\s+", " ")

Hope this helps😇

1 Like

@Anelisa_Bolosha1

Add on… the regex you have written is also correct and it should work
check variables you are checking. StringBody variable should contain the text with replaced (2+spaces) with " "

This is sample input and output

1 Like

result = System.Text.RegularExpressions.Regex.Match(yourString, “(\d+(?:.\d+)?)\s*\p{L}”).Groups(1).Value

1 Like

Perfect thank you so much it worked.

:slight_smile:

1 Like

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