Hi fellow ruby-ers
I don't understand this regular expression
/\S+ </
It is from the ruby quiz "Secret Santas"
http://www.rubyquiz.com/quiz2.html
What does it exactly mean ? The "<" confuses me
Greetings & Thanks
···
--
Posted via http://www.ruby-forum.com/ .
ts1
(ts)
22 July 2006 13:05
2
/\S+ </
Well the format for a line is
FIRST_NAME space FAMILY_NAME space <EMAIL_ADDRESS> newline
The regexp will select any non-whitespace character followed by a space and
the character <
'<' was added to extract the FAMILY_NAME, without this character
(i.e. with /\S+ /) the regexp will match FIRST_NAME
Guy Decoux
In this case, the '<' is just a character. So, it's looking for a series of one or more non-whitespace characters, followed by a space, followed by a '<'
/\S+ </.match("blah match_this_section < but not this")[0]
=> "match_this_section <"
matthew smillie.
···
On Jul 22, 2006, at 13:51, Diego Amicabile wrote:
Hi fellow ruby-ers
I don't understand this regular expression
/\S+ </
It is from the ruby quiz "Secret Santas"
Ruby Quiz - Secret Santas (#2)
What does it exactly mean ? The "<" confuses me