« Return to Thread: Unable to update stock prices

Re: Unable to update stock prices

by Midahed :: Rate this Message:

| View in Thread

Thomas Baumgart wrote:
Hi all,

on Sunday 16 November 2008 18:50, Midahed wrote:

[...]

> I can't even understand why "([^,"]*)",.* is used for the symbol!  But
> that bit works, so it must be my understanding that's adrift.

Try

  [^,]*,[^,]*,[^,]*,"?([^,"]*)"?

as RE for the date, which should do the trick for the URL

  http://uk.finance.yahoo.com/d/quotes.csv?s=%1&f=sl1t1d1

(notice: I removed the 'old' part in the URL)

Explanation:

  [^,]*,

reads as 'zero or more' 'character except comma' followed by comma.

  *    is zero or more
  [^,] match any character but a comma
  ,    match a comma

Now to the stuff at the end:

  "?

reads as 'a single optional quote' (one or none)

  [^,"]*

almost like above, but 'zero or more' 'character except comma and quote'
and the part enclosed in parenthesises is what KMyMoney is looking for.

[...]

p.s. Hope this works, I haven't tested it at all (well, just using the
QRegExp debugger inside KDevelop)
Thanks Thomas.  Much appreciated, but I'm afraid it didn't work - I got exactly the same result in that the status message doesn't say anything about reading the date.

I'd understood the general principles of RE OK and, now that you've confirmed that I'm on the right general track, I'll do some more experimenting using your suggestion as a base.  However, I still don't understand the RE that's used to extract the symbol:-  

"([^,"]*)",.*

That says to me "look for a string that's in quotes, that doesn't contain a comma or a quote, and is terminated by the first comma you find".   However, the data I'm getting from Yahoo doesn't have quotes around the symbol, but the extraction of the symbol from the downloaded data works OK.  I fail to understand how!   The RE that's used seems to specifically require the quotes around the string that it's trying to match, but they aren't present in the source data.

Thanks again,

Mike

 « Return to Thread: Unable to update stock prices