[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Another regular expression question

tuyet.ctn

7/13/2005 12:01:00 AM

I have a select box that contains two items that are similar:
1) GICS Sector
2) Sector

How do tweak this command to select the second item "Sector" instead of
"GICS Sector"?

irb(main):065:0> ie.frame("customizeRemoteContent").select_list(:id,
"availableColumnsSelectBox").select(/Sector/)

This selects "GICS Sector"

I have tried select([Sector]) and other permutations but can't seem to
find the right one. I did go to this site to read up more about
regular expression, but the examples are not very clear. Appreciate
your suggestions!
http://www.ruby-doc.org/docs/ProgrammingRuby/html/int...

7 Answers

Tim Hunter

7/13/2005 12:24:00 AM

0

tuyet.ctn@mscibarra.com wrote:
> I have a select box that contains two items that are similar:
> 1) GICS Sector
> 2) Sector
>
> How do tweak this command to select the second item "Sector" instead of
> "GICS Sector"?
>
> irb(main):065:0> ie.frame("customizeRemoteContent").select_list(:id,
> "availableColumnsSelectBox").select(/Sector/)
>
> This selects "GICS Sector"
>
> I have tried select([Sector]) and other permutations but can't seem to
> find the right one. I did go to this site to read up more about
> regular expression, but the examples are not very clear. Appreciate
> your suggestions!
> http://www.ruby-doc.org/docs/ProgrammingRuby/html/int...
>

Look for "anchors". The sequence "\A" matches the beginning of a string,
so the regular expression /\ASector/ will match only strings that start
with "Sector".

Similarly "\z" matches the end of a string.

tuyet.ctn

7/13/2005 1:46:00 AM

0

Thanks, Timothy, I did see this in the Ruby Regular Expression web
site, but when I tried it, I got an error:
irb(main):009:0> ie.frame("customizeRemoteContent").select_list(:id,
"availableColumnsSelectBox").select(/\ASector/)
Watir::Exception::NoValueFoundException: Selectbox was found, but
didn't find item with text of (?-mix:\ASector) from
C:/ruby/lib/ruby/site_ruby/1.8/watir.rb:3306:in
`select_item_in_select_list'
from C:/ruby/lib/ruby/site_ruby/1.8/watir.rb:3284:in `each'
from C:/ruby/lib/ruby/site_ruby/1.8/watir.rb:3284:in
`select_item_in_select_list'
from C:/ruby/lib/ruby/site_ruby/1.8/watir.rb:3261:in `select'
from (irb):9
from :0

Kelly Felkins

7/13/2005 8:15:00 AM

0

I highly recommend these resources:

http://www.weitz.de/re...
This is a windows application that you can use to interactively build
regular expressions.

http://samuelfullman.com/team/php/tools/regular_expression_tes...
This is a web based regular expression tester.

-Kelly


On 7/12/05, tuyet.ctn@mscibarra.com <tuyet.ctn@mscibarra.com> wrote:
>
> Thanks, Timothy, I did see this in the Ruby Regular Expression web
> site, but when I tried it, I got an error:
> irb(main):009:0> ie.frame("customizeRemoteContent").select_list(:id,
> "availableColumnsSelectBox").select(/\ASector/)
> Watir::Exception::NoValueFoundException: Selectbox was found, but
> didn't find item with text of (?-mix:\ASector) from
> C:/ruby/lib/ruby/site_ruby/1.8/watir.rb:3306:in
> `select_item_in_select_list'
> from C:/ruby/lib/ruby/site_ruby/1.8/watir.rb:3284:in `each'
> from C:/ruby/lib/ruby/site_ruby/1.8/watir.rb:3284:in
> `select_item_in_select_list'
> from C:/ruby/lib/ruby/site_ruby/1.8/watir.rb:3261:in `select'
> from (irb):9
> from :0
>
>
>

tuyet.ctn

7/13/2005 5:49:00 PM

0

Thank you for your suggestions.
I was able to decipher what I need using the web based regular
expression tester you mentioned (I bookmarked it)
I also used this site to look up the different permutations that I can
use:
http://www.regular-expressions.info/quick...
The right answer for what I need is:
/[^GICS Sector]Sector/

tuyet.ctn

7/13/2005 5:49:00 PM

0

Thank you for your suggestions.
I was able to decipher what I need using the web based regular
expression tester you mentioned (I bookmarked it)
I also used this site to look up the different permutations that I can
use:
http://www.regular-expressions.info/quick...
The right answer for what I need is:
/[^GICS Sector]Sector/

tuyet.ctn

7/13/2005 5:49:00 PM

0

Thank you for your suggestions.
I was able to decipher what I need using the web based regular
expression tester you mentioned (I bookmarked it)
I also used this site to look up the different permutations that I can
use:
http://www.regular-expressions.info/quick...
The right answer for what I need is:
/[^GICS Sector]Sector/

Logan Capaldo

7/13/2005 9:37:00 PM

0


On Jul 13, 2005, at 1:50 PM, tuyet.ctn@mscibarra.com wrote:

> Thank you for your suggestions.
> I was able to decipher what I need using the web based regular
> expression tester you mentioned (I bookmarked it)
> I also used this site to look up the different permutations that I can
> use:
> http://www.regular-expressions.info/quick...
> The right answer for what I need is:
> /[^GICS Sector]Sector/
>
>
>

That's actually only a coincidence that that works. [ ] means match
one occurence of the characters inside the [ ]. [^ ] means match one
occurence of any character NOT between the [^ ]

Give it a shot by using SIGS Sector as an example string. It will
still match. Of course in this case its not that important since it
does what you need, however the correct regexp should be /^Sector/.