How to split string based on special character

Hi guys i’m facing a issue of splitting the name based on special character.

Ex: 1) Ram kumar & rajesh & raja reddy
2)10-01-2021 & 15-01-2021

o/p : 1) Ram kumar
rajesh
raja reddy

  1. 10-01-2021
    15-01-2021

I want this type of output . Can anyone help me how to solve this

Hi @ranaprathap928,

Check this below link

And also you can use split function similar way can able to exact value using special character
Yourvariable.split("&",TocharArray)(0)

Hi @ranaprathap928,

Here is a quick xaml example for you that how can you achieve this resultSplitExample.xaml (8.7 KB)

Cheers !


array1=str.split("&"c).ToArray
string.Join(vbCr,array1)

@ranaprathap928

with the menitioned statements the Array items maybe still need to get trimmed
grafik

following statement is doing it in one go:

YourStringVar.Split("&"c).Select(Function (x) x.Trim).toArray

or also removing empty split results on same time:
YourStringVar.Split({"&"}, StringSplitOptions.RemoveEmptyEntries).Select(Function (x) x.Trim).toArray

Thanks @Shikhar_Tandon it’s working

Hello Rana,
In this video I do a lot of stuff with String and DateTime:

0:35 Examples for Substring functions
4:10 IndexOf and LastIndexOf
5:00 SubString working together IndexOf and LastIndexOf
6:45 Split string by character
8:50 Split string by string
12:00 Lower Case and Upper Case
12:45 Trim
15:05 Compare strings in multiple ways
19:05 Resume of all the String function part
20:05 DateTime to string in multiple ways
23:00 AddDays get DayofWeek
25:40 Convert from String to DateTime
26:20 Compare DateTime

Thanks,
Cristian Negulescu

2 Likes

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