How to use Split or use Regex if I want to Split a list of text by “.” , but if the text have two or more “.” (example : “Hello… Brother”) they still only define to 1 string ?
Because if i use variableString.Split(Cchar(“.”)) if the String is “Hello… Brother” it will be “Hello”
“.”
“.”
“.”
“Brother”
@Ricky_Fenardo What will be the ideal case when we want to split the string with “.” , if we want to use regex we need to make a fixed pattern like what will be succeeding pattern after a full stop.
Like Space(Whitespace) or any characters will be there after the required full stop we are looking for.
Maybe it will works if split by “.” and a space (whitespace). So can you tell me the Regex how to split by “.” and space?
I had try this System.Text.RegularExpressions.Regex.Split(text,“.+”) but it not works…
The dots are just regular periods so System.Text.RegularExpressions.Regex.Split(inputText, "\.+") should work fine. See the attached file for an example: SplitByPeriod.xaml (6.6 KB)
Hmmm… actually i want to keep the " Kresk… and Dito menginjak ranting kering" is still into 1 line. The output i want is like “Kresk Dito menginjak ranting kering” and “Hii aku bergidik ngeri kalau mengingat kejadian itu”, not separated like that (“Kresk”, “Dito menginjak ranting kering”)
Then you need to remove the periods (“…”, “…”, etc) first before the split. We need to do it in two steps since there’s not always a space after the periods: replace two or more periods with a space and then replace the double spaces with a single space.
Hi.
sentences = text.Replace(“…”,“TRIPLEDOT”).Replace(“..”, “DOUBLEDOT”).Split(“.“c)
for each sentence in sentences
sentence.Replace(“DOUBLEDOT”,”..”).Replace(“TRIPLEDOT”,“…”)