i am trying to get an array that contain of aaaaa,bbbbb,ccccc as split output below.
a_string = "aaaaa[x]bbbbb,ccccc";
split_output a_string.split.split(%r{[,|........]+})
what supposed i put as replacement of …….. ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No need for a regex when it’s just a literal:
If you want to split by “open bracket…anything…close bracket” then:
Edit: I’m still not sure what your criteria is, but let’s guess that what you are really doing is looking for runs of 2-or-more of the same character:
Edit 2: If you want to split by either the of the literal strings
","or"[x]"then:The
|part of the regular expression allows expressions on either side to match, and the backslashes are needed since otherwise the characters[and]have special meaning. (If you tried to split by/,|[x]/then it would split on either a comma or anxcharacter.)