Replacing String

Hey community I have a simple problem that i couldn’t solve can you please help me ! :slight_smile:

The Data that 1i extract from my PDF is Like that "ABCD EFG H 68 5"and I want it to look like this “ABCD_EFG_H 68 5” using replace activity and regular expressions Thaaaaank you guys !:slight_smile:

So you only want an underscore in between the letters? In that case you can use the following in an assign activity:

yourString = System.Text.RegularExpressions.Regex.Replace(yourString, “(?<=[A-Z]) (?=[A-Z])”, “_”)

From the top of my head, try and see if it works :slight_smile:

3 Likes

Hi @Mehdi_El_Aissi,

You can use String_str= System.Text.RegularExpressions.Regex.Replace(your_String, “(?<=[A-Z])\s+", "_") ,if you would like to replace string like “ABCD_EFG_H_68 5”

Warm regards,
Nimin

2 Likes

@Mehdi_El_Aissi, this is what you want: String.Replace(" ", “_”)

Why people are using look behind regex a lot in UIPath forum? :smiley:
This can be dangerous.