ruby - How to split a string behind a particular marker -
ruby - How to split a string behind a particular marker -
i split string array. i'm looking first word isn't exclusively capitalised, , want split behind that.
"word word cccc cccc cccc cccc ccccc cccc....." or
"word cccc cccc cccc cccc ccccc cccc....." should result in
["word word", "cccc cccc cccc cccc ccccc cccc....."] or
"word", "cccc cccc cccc cccc ccccc cccc....." what best way this?
you can utilize next regex:
(?=\p{zs}(\p{lu}\p{ll}+.*))\p{zs} explanation:
i assume have input string starts allcaps word(s) , rest of string not. so,
(?=\p{zs}(\p{lu}\p{ll}+.*)) - positive look-ahead checking if have space (\p{zs}) followed capital letter, non-capitalized letter, , characters newline, number of repetitions \p{zs} - consume space not include array element upon split. ruby string
Comments
Post a Comment