Split string that has new line and a lot of spaces in it

i want to split the following string:
Client ID: RU90268
Client Name: Veda Blaylock
Client Country: Germany

and get value RU90268, Veda Blaylock and Germany

there is a new line and it is followed by 19 spaces

@Aishwarya_Bhargava - Is the new line in between each line ? could you please clarify?

it is in between all the three lines, its occurring twice in the whole string

You can use Regex or split method to get the desired output

i am not good at writing regex expression, so can you help me with that

i tried using split but its not working
Split(ClientDetails," “)(1).Split(”:"c)(1).Trim
i used this

First split using Environment.newline and then Split using “:”

it is showing index out of bound

@Aishwarya_Bhargava - This post will help you…

If you are still not able to solve using string.Split method …please let me know, I will provide 3 Regex patterns…


i was able to get client id but nothing else

can you please help

Hi @Aishwarya_Bhargava,
Can you please try this:

(?<=\ \w+:\ )(\w*\ \w*)


that is working with the client name

Hi @Aishwarya_Bhargava,
Can you please try this:


Check with the below mentioned link for further clarification:

Thank you

it worked for all of them after making some adjustments

thankyou :slight_smile:

1 Like

Hi @Aishwarya_Bhargava,

Happy to help!
Please try with this also:


1 Like

okay will do

1 Like

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