Hello!
I saw a few topics around stringmanipulation, but I got lost, and did not find a good clean solution so far.
I need to manage a string where the format is:
(note: the actual string uses a “asterisk” before extra, but the edit of this chat make it messy with BOLD characters, so i’ve substituted with a plus sign.)
I want to isolate “information”
I found a workaround, but it looks overcomplicated to me.
Any suggestion? here below what I have
1- removing the extra seemed reasonably easy (extra is a repetitive info, so i use mystring.replace(“extra",“”).replace("”,“”) <<-- yes the “*” is not removed from the 1st replace…
2- Removing AAAA_BBBB_ is a challenge. I’m doing a sequence of ‘indexof’ then substring that dose not seem that nice
Thx to all the replies.
I’m close but not done completely.
Here’s a test string that will probably clarify what I need to achieve.
I need to chop away after the 2nd “_”; I want to retain “Information_Difficult”
TEST_test33_Information_Difficult*Extratoremove
Opposite to the examples, I’m not splitting after the 1st “_”
I did some trials, but no success so far!
An additional option for a dynamic length string which only relies only on the underscores and the asterisk. Lets remove the unwanted text rather than match the text we need.
You will need to use a regex replace by inserting the below into an ‘Assign’ activity:
System.Text.RegularExpressions.Regex.Replace(youStr, “(?<=\*).*|^[^_\n\r]+_[^_\n\r]+_”, “”)
Examples - noting the highlighted text will be removed
1 word: