With a regex such as rg = r"([[:alpha:]]+|[[:digit:]]+|(?:[[:punct:]]|[[:blank:]])+)", you can separate the runs of like characters. Here I’m using character classes, but you could also replace those with more specific lists if you know what will and won’t appear in your text. Additionally, whitespace is treated separately from letters among the character classes, so you have the choice of grouping the whitespace with the letters or with the punctuation. (There is also the [[:space:]] class which matches space, tab, and newlines.) The website https://regex101.com/ is a great tool for writing and testing regex’s.
str1 = "1a2b3c"
str2 = "123abc456cde"
str3 = "12a +) 3b"
(Notice I added some spaces to str3 to demonstrate the grouping of spaces.)
julia> collect(eachmatch(rg, str1))
6-element Vector{RegexMatch}:
RegexMatch("1", 1="1")
RegexMatch("a", 1="a")
RegexMatch("2", 1="2")
RegexMatch("b", 1="b")
RegexMatch("3", 1="3")
RegexMatch("c", 1="c")
julia> collect(eachmatch(rg, str2))
4-element Vector{RegexMatch}:
RegexMatch("123", 1="123")
RegexMatch("abc", 1="abc")
RegexMatch("456", 1="456")
RegexMatch("cde", 1="cde")
julia> collect(eachmatch(rg, str3))
5-element Vector{RegexMatch}:
RegexMatch("12", 1="12")
RegexMatch("a", 1="a")
RegexMatch(" +) ", 1=" +) ")
RegexMatch("3", 1="3")
RegexMatch("b", 1="b")