I am having trouble with a complicated string manipulation problem.
It seems like my activity should work but it does not
- I have a file called results, which has a column called total price
- The total price I am trying to correct is $155.3377 $1553377
- Return only $155.3377 deleting everything after the second $
- I declare a price variable “Price”
- If Price.ToString.Contains("$")
- Assign TotalPrice = Row(“TotalPrice”).ToString
- Assign TotalPrice = TotalPrice.remove(TotalPrice.indexOf(("$"), TotalPrice.indexOf("$") + 1)).ToString
My result for the price $155.3377 $1553377 returns the same value $155.3377 $1553377
Can someone help me return just $155.3377
Try below expression.
InputString = "$155.3377 $1553377"
Thank you for the idea but I am still getting the same result.
Thank you for your idea but unfortunately, I am still getting the same result. I tried several examples.
I am now wondering if there is something wrong with my assign activity and IF activity.
Can you please print the your input string before applying above string manipulation on it and check it once.
Can’t you just split by blank space?
It looks like the solution is working but after $ is removed, at the end I am printing the orginal value.
Nice to hear from you!
Actually I cannot use the space as a delimiter since in some cases I could have spaces in between the numbers.
Hope you are doing well my friend
What about this?
I assigned a new variable after the the REGEX method and I appear to be getting the appropriate result.
Now I need to figure out how to manipulate my new variable to clean up the rest of the formatting.
I will share my results as my investigation continues.
The regex activity does not work when I have a price such as this: $ 1 9 . 0170 $ 1 9 0170
Do you know how I could make regex work in this case?
Can you try the following?
Thank you for the quick reply.
This new method appears to work where the output is $ 1 9 . 0170
I have two additional questions
Could you recommend a way to remove the spaces in-between the numbers? I was not sure if I could use .replace(" “,”") with regex or not
Could you recommend a good resource to learn regex? It seems simple but I never really grasped it.
I also noticed that I have another strange price format if you have any ideas
This price is coming across is a few different formats which makes it very tricky
$ 0 0000 . $ 0 . 0000
$ 0 . 0000
$ 0 0000 .
The desired output would be $0.0000
Do you need to get the data as it appears? If you can accept $0.0000 as $0 ,the following will work.
If the number of decimal places is always four, the following might be better.
Does your first solution apply to a dynamic number of decimals?
My results can sometimes be .0 or .00 or .000 or .0000
First solution proposed:
If there is $ sign before the above string, it will work as the following.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.