Question about a regular expression

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

“D” == Diego A. [email protected] writes:

D> /\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

On Jul 22, 2006, at 13:51, Diego A. wrote:

What does it exactly mean ? The “<” confuses me
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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs