Split the given string

Hey,
Suppose I have an input value say, ₹1,23,987 this is given as a string value. I want the output to be ₹ and 123987 i.e. the currency symbol and the number is supposed to be separated. How to I do that? Any ideas?
Thanks in advance.

@Amrita_Narayan

Try this:

  yourStr = "₹1,23,987"
  
   requiredStr = yourStr.Substring(1,yourStr.Length)

@Amrita_Narayan,
You can convert the string currency value using the below code into a decimal value.
This will support negative numbers, and will stop if it finds a second period value, thus reducing the number of strings it returns that are not valid decimal values

Decimal.Parse(Regex.Match(input, "-?\d{1,3}(,\d{3})*(\.\d+)?").Value)

For Currency symbol

Symbol= yourStr.Substring(0,1)

For Numbers

Numbers= yourStr.Substring(1)

This works perfectly fine!
Thank you!

Welcome!

Happy Automation…:blush:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.