I have this label on a web page - we'll call it PageHeadingLabel - and the contents change based on selected user. I need to know how to capture the *last* part of that string to a variable.
Here's the code that calls up the text:
$main_frame.span(:id, /PageHeadingLabel/).text
And the output is something like: "Good Morning, <user name>"
e.g. "Good Morning, Bob" or "Good Morning, Jamaican Bobsled Team" or whatever.
I *need* to capture the user name to a variable (let's call it 'user_name')
-> I have looked through all the String class methods, but I haven't found anything straightforward that will help me output the last part of a random-length string. I managed to get the Element Reference [] to spit out what I need but it's kind of gross-looking (mostly because I don't want to work with intermediate variables).
I browsed through the Regular _expression_ stuff, but I still haven't had a chance to read up on it. My amateur re commands keep returning true, false, nil, etc. but not actual strings.
Does anyone know of a simple way to set a variable to something like this:
user_name = $main_frame.span(:id, /PageHeadingLabel/).text (from ', ' to the end)
?
help. please.
_______________________________________________ Wtr-general mailing list [email protected] http://rubyforge.org/mailman/listinfo/wtr-general
