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

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -