Split a character vector into individual characters? (opposite of paste or stringr::str_c)

Yes, strsplit will do it. strsplit returns a list, so you can either use unlist to coerce the string to a single character vector, or use the list index [[1]] to access first element. x <- paste(LETTERS, collapse = “”) unlist(strsplit(x, split = “”)) # [1] “A” “B” “C” “D” “E” “F” “G” “H” “I” … Read more

How to split a string into words. Ex: “stringintowords” -> “String Into Words”?

Let’s assume that you have a function isWord(w), which checks if w is a word using a dictionary. Let’s for simplicity also assume for now that you only want to know whether for some word w such a splitting is possible. This can be easily done with dynamic programming. Let S[1..length(w)] be a table with … Read more

Splitting String in VBA using RegEx

To split a string with a regular expression in VBA: Public Function SplitRe(Text As String, Pattern As String, Optional IgnoreCase As Boolean) As String() Static re As Object If re Is Nothing Then Set re = CreateObject(“VBScript.RegExp”) re.Global = True re.MultiLine = True End If re.IgnoreCase = IgnoreCase re.Pattern = Pattern SplitRe = Strings.Split(re.Replace(text, ChrW(-1)), … Read more