You need regular expressions (http://www.regular-expressions.info/ruby.html).
If "X" means letter this will do
it:
irb(main):003:0> ie.text =~
/(\w){3},(\w){4},(\w){4},(\d|\w){4},/
=> 507
irb(main):004:0> my_var = Regexp.last_match(0)
=> "XXX,XXXX,XXXX,XXXX,"
=> 507
irb(main):004:0> my_var = Regexp.last_match(0)
=> "XXX,XXXX,XXXX,XXXX,"
Now you have "XXX,XXXX,XXXX,XXXX," in variable
my_var.
"\w" will match any letter, "(\w){3}" will match three
letters
if "X" is:
- number: replace \w with \d
- number or letter:
replace \w with \d|\w
- anything: replace
\w with . (dot)
Zeljko
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of jim che
Sent: Monday, November 21, 2005 10:19 AM
To: [email protected]
Subject: [Wtr-general] How to get some certain informations of page
Hi all
I want to get some ceratin informations of page.For
example ,in the page there are some data like "XXX,XXXX,XXXX,XXXX,".I want to
get such format data and store to a var, how should I do it?
Thank you for any help
jim
Yahoo! FareChase - Search multiple travel sites in one click.
_______________________________________________ Wtr-general mailing list [email protected] http://rubyforge.org/mailman/listinfo/wtr-general
