Hi I try to separate input like this : <Text1><Text2><Text2>..<TextN>
in a array who only have each text in each index, how I can use split with double parameters?
I try make a double split but doesn't work:
request = client.gets.chomp
dev = request.split("<")
split_doble(dev)
dev.each do |devo|
puts devo
end
def split_doble (str1)
str1.each do |str2|
str2.split(">")
end
end
When you have a string like this
then you can extract the text between the
<
and>
chars like that:/\w+/
is a regular expression that matches a sequence of word characters (letter, number, underscore) and therefore ignores the<
and>
characters.Also see docs about
String#scan
.