How to use Split or use Regex if I want to Split a list of text by "."

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”

I’m very happy for any solutions… Thanks Before.

Hi,

Can you try the following?

 text.Split({"."c},StringSplitOptions.RemoveEmptyEntries)

or

System.Text.RegularExpressions.Regex.Split(text,"\.+")

Regards,

1 Like

@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.

I think it still have same output :frowning: , the output is

But unfortunately… i want to get this word get splitted to be 1 string (this is the text input)

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…

Hi,

It seems is not 3 periods but single character.
So, can you try the following expression?

text.Split({"."c,"‥"c,"…"c},StringSplitOptions.RemoveEmptyEntries)

Regards,

1 Like

Hi Yoichi,
the following expression get an error like this…

@Ricky_Fenardo Can you provide the text file that you get after you extract the data from the website?

Remove all the c. C after a string is the same as ToCharArray(). It is not required here since you’re already defining the array with {…}

text.Split({".","‥","…"},StringSplitOptions.RemoveEmptyEntries)

@Ricky_Fenardo Hope this will solves your issue System.Text.RegularExpressions.Regex.Split(variable1,"(?<=\w)\.+")

Hello @Ricky_Fenardo - welcome to the community :partying_face:

If you want to learn Regex - check out my Regex Megapost :blush:

Regex help tutorial MEGAPOST – Making your first Regex post, Reusable Regex Patterns, Regex Troubleshooting, Sample Workflow and more

Hi,
Did you input as 3 periods? is not 3 periods but single character.
If it’s difficult input , can you copy the following Split method.

text.Split({"."c,"‥"c,"…"c},StringSplitOptions.RemoveEmptyEntries)

Regards,

after I try it, that expression still have same output

Still same output… no different with expression
text.Split({“.”,“‥”,“…”},StringSplitOptions.RemoveEmptyEntries)

Hi @Ricky_Fenardo,

Could you use a Write Text File activity to save your input text to a file and then upload it here so we can have a look?

Nvm. Found the website (Cerpen Anak: Rumah Nomor 6 - Bobo)

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)

image

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.

isiBobo = System.Text.RegularExpressions.Regex.Replace(isiBobo, "\.{2,}", " ").Replace("  ", " ")
ListIsiBobo = isiBobo.Split({"."},StringSplitOptions.RemoveEmptyEntries)

image

image

Updated version: SplitByPeriod.xaml (7.0 KB)

1 Like

Hi.
sentences = text.Replace(“…”,“TRIPLEDOT”).Replace(“..”, “DOUBLEDOT”).Split(“.“c)
for each sentence in sentences
sentence.Replace(“DOUBLEDOT”,”..”).Replace(“TRIPLEDOT”,“…”)

Thankyou very much @ptrobot case solved… and for everyone thankyou too for any solution gived to me…

1 Like