Junkone
(Junkone)
6 August 2006 23:45
1
I have a string
<A
HREF="http://stockcharts.com/h-sc/ui?s=ACN.TO&id=p41804099534&a=81626743&listNum=30 ">
<IMG SRC="/images/ico_candle_on.gif" BORDER=0 ALT="Default
SharpChart"></A><A HREF="/webcgi/wb.exe?gall.web+ACN.TO "><IMG
SRC="/images/ico_trendline_on.gif" BORDER=0 ALT="Gallery Page"></A><A
HREF="/def/servlet/SC.pnf?c=ACN.TO ,P&listNum=30"><IMG
SRC="/images/ico_pnf_on.gif" BORDER=0 ALT="P&F Chart"></A>
When i use the Regulator to create a regex it matches. my sample is
"http(.)+["]
It returns
"http://stockcharts.com/h-sc/ui?s=ACN.TO&id=p41804099534&a=81626743&listNum=30 ">
However when i use ruby, it returns
When i use ruby with syntax a.scan(/"http(.)+["]/)
It returns [["t"]]
can someone help determine what error i am doing
Hi --
I have a string
<A
HREF="StockCharts.com ;
<IMG SRC="/images/ico_candle_on.gif" BORDER=0 ALT="Default
SharpChart"></A><A HREF="/webcgi/wb.exe?gall.web+ACN.TO"><IMG
SRC="/images/ico_trendline_on.gif" BORDER=0 ALT="Gallery Page"></A><A
HREF="/def/servlet/SC.pnf?c=ACN.TO,P&listNum=30"><IMG
SRC="/images/ico_pnf_on.gif" BORDER=0 ALT="P&F Chart"></A>
When i use the Regulator to create a regex it matches. my sample is
"http(.)+["]
It returns
"StockCharts.com ;
However when i use ruby, it returns
When i use ruby with syntax a.scan(/"http(.)+["]/)
It returns [["t"]]
can someone help determine what error i am doing
When you use parenthetical captures, String#scan returns successive
arrays of those captures. In the case of your scan, you've matched
the string once, and captured "t" in the first () group.
If you want a substring that starts with "http and ends with ", you
can do:
a[/"http[^"]+"/]
David
ยทยทยท
On Mon, 7 Aug 2006, junkone1@gmail.com wrote:
--
http://www.rubypowerandlight.com => Ruby/Rails training & consultancy
----> SEE SPECIAL DEAL FOR RUBY/RAILS USERS GROUPS! <-----
http://dablog.rubypal.com => D[avid ]A[. ]B[lack's][ Web]log
Ruby for Rails => book, Ruby for Rails
http://www.rubycentral.org => Ruby Central, Inc.