C_M1
October 4, 2023, 9:14am
1
I have this problem where I get a string using get full text and it gives me the below string:
The below contains 10 new line spaces
Ingredients.txt (4.1 KB)
I want it to be like below using any string manipulation or regex:
Thank you in advance for your help!
Hi
Use this expression in assign activity
stroutput = System.Text.RegularExpressions.Regex.Replace(yourString,β^\s+β,ββ,System.Text.RegularExpressions.RegexOptions.Multiline).Trim
Cheers @C_M1
1 Like
C_M1
October 4, 2023, 9:21am
3
Thank you this one works! By the way, how did you come up with that solution? I just want to know more about regex and string manipulation, if you can recommend some tutorials it will be helpful as well! Thanks!
1 Like
ppr
(Peter Preuss)
October 4, 2023, 9:22am
4
give a try at the following:
Assign Activity
strCleansed =
String.Join(Environment.NewLine,System.Text.RegularExpressions.Regex.Split(strInputText, "[\s]+"))
Check this out for more insights
This CheatSheet introduces the basic use of regex functions. With further examples also special cases are presented.
Introduction
From the namespace System.Text.RegularExpressions following methods are offered:
Regex.Match
Regex.Matches
Regex.isMatch
Regex.Replace
Regex.Split
A simple usage for example would look like this:
[grafik]
Recommendation:
add System.Text.RegularExpressions to the imports:
[grafik]
it allows to use the shortened statement, as the namespace part can be ommitedβ¦
Cheers @C_M1
1 Like
ppr
(Peter Preuss)
October 4, 2023, 9:22am
6
1 Like
system
(system)
Closed
October 7, 2023, 9:23am
7
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.