Splitting the string

Hi,

I want split a string Example Input - ABC9999

Output1 - ABC
Output2 - 9999

Example2 Input - XYZABC9999

Output1 - XYZABC
Output2 - 9999

Hope you understand…!!

Thanks,
Rishi

1 Like

@Rishik_Chowdary , You can use regex

System.Text.RegularExpressions.Regex.Match(YourString,"\D+").tostring.trim   Output1 - ABC
System.Text.RegularExpressions.Regex.Match(YourString,"\d+").tostring.trim      Output2 - 9999

HI @Rishik_Chowdary

You can try this

For Number
System.Text.RegularExpressions.Regex.Match(“ABCD9999”,“\d+”).ToString

For Word
System.Text.RegularExpressions.Regex.Match(“ABCD9999”,“\D+”).ToString

image

Regards
Sudharsan

image
image

@Rishik_Chowdary
we can use Regex and return an array of Strings by following

System.Text.RegularExpressions.Regex.Match(YourTextVar,"([A-Z]+)(\d+)").Groups.Cast(Of Group).skip(1).Select(Function (g) g.Value).toArray

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