sathwik19
(DemonSecrets)
November 17, 2020, 7:10pm
1
Hi I need to replace a string by it’s index position
Str1 = 0110000505
i want to replace 05 with 99 when i use replace functions it is replacing it as 0110009999 but i want to replace only last part of 05 so the expected output will be as 0110000599.
Any Suggestions thanks in advance.
ptrobot
November 17, 2020, 7:35pm
2
You should be able to do that with Substring:
Str1 = Str1.Substring(0, Str1.Length-2) + "99"
See this post to learn about string manipulation:
Hi,
if you are a beginner in the world of automation and would like to know how you can manipulate text based on the solutions available in the VB.NET code and using REGEX (regular expressions) then you are in the right place.
In the topic below, you will learn how to easily extract data from any part of the search text using various methods.
The topic includes solution examples with descriptions and graphics to better understand the topic for functions such as:
Split
Substring
Left
Right
R…
2 Likes
sathwik19
(DemonSecrets)
November 17, 2020, 7:50pm
3
Thanks for your response.
Your solution works if the replacing numbers are at the end what if i want to replace first part of “05” so the output would look like
01100009905
ptrobot
November 17, 2020, 8:00pm
4
Then you will need to use IndexOf also to find the position of “05” so you can get the parts before and after “05”.
pos = Str1.IndexOf("05")
Str1 = Str1.Substring(0, pos) + "99" + Str1.Substring(pos+2)
pos is of type Int32
Hello @sathwik19
Just throwing another alternative out there from @ptrobot
You could use a Regex ‘Replace’ activity.
Scenario 1
Scenario 2
Hopefully you get the right solution for your needs
1 Like