Credit portal




An Example

what are y shares

<Q> Is there a function to return a string between two delimiters?

<B> i don't understand what you mean, but i doubt there's already a function

<C> split and slice

<D> partition too

<Q> I tried partition

<Q> I was trying to use built-ins to get the number between something like this in a string "attribute1: 50.223, attribute2: 442.1"

<D> why not just parse the string?

<Q> I thought there may have been some built in parsing stuff

<D> pairs = [x.strip() for x in s.split(",")]; attribs =

<D> there's a few libraries, but simplistic formats are easy enough -- if you don't care about error handling

<D> changing the source to use a well known format, e.g. json or yaml, is preferred when possible

<Q> This code actually comes from HTML

<Q> but I don't know how to parse

Javascript with HTMLParser or whatever it's called

<D> is it merely embedded in html, or some mangled version of html?

<Q> It's embedded in the HTML

<D> if it's javascript (and that is, except for missing outer braces), json can probably parse it

<Q> thanks

<D> I didn't say it explicitly: json only parses data structures, not js code

<Q> That's all I need parsed is a data structure

The problem is really about how to parse JavaScript data structures, not find "a string between two delimiters", yet it takes quite a bit of time and intuition to get to the real issue.

This is easier to do in a fully interactive chat (regardless of what mode), but on a SE site, where you polish a post a bit, post it, and then have 5-30 mins, or longer, before feedback, it really helps to head in the right direction from the start.

Category: Forex

Similar articles: