Split data based on some criteria

Hi,

I want to split this data “11,979.00165.0012,144.00599.000.000.0012,743.00”

Need to split data like this “11,979.00 165.00 12,144.00 599.00 0.00 0.00 12,743.00”

After “.” the next 2 digits need to be appended with it and after it a space need to be inserted

If precision is always .00,
then you can use Replace method to get the required string.

YourString.Replace(".00",".00 ")

Regards,
Karthik Byggari

Hi @KarthikByggari Very happy to see that u have replied but i am not sure that the elements that come after “.” may not be zero itself.

i need to split data like what ever comes after 2 decimal places need to insert a space in between the next element

Okay. Let me check again.

Hi @jishnupnair1996,

Say your input variable is: strYourInput = “11,979.00165.0012,144.00599.000.000.0012,743.00”;

Try this:

System.Text.RegularExpressions.Regex.Replace(strYourInput,"(?<=.\d{2})"," ");

Make sure you add a back slash before the period character(.) (?<=\.\d{2})

2 Likes

Make sure you add a back slash before the period character(.) (?<= \.\d{2})

I had added the back slash in my earlier comment, but I don’t know why the resultant preview on the forum skips the backslash.

2 Likes

Hi @siddharth

yeah its working now
Thank you

1 Like

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