parsing

FParsec failing on optional parser

穿精又带淫゛_ 提交于 2021-02-07 21:10:34
问题 I am currently learning the FParsec library, but I have come across an issue. When I want to parse an optional string and continue parsing as normal afterwards, FParsec will return a fatal error on the optional parser, rather than returning None as I expect. The below working code sample illustrates my point: open System open FParsec type AccountEntity = | Default | Entity of string let pEntity = let isEntityFirstChar c = isLetter c let isEntityChar c = isLetter c || isDigit c (many1Satisfy2L

Extract JSON object from html using PHP regex

耗尽温柔 提交于 2021-02-07 18:12:51
问题 After reading all related threads i can not find anything that shows regex that is capable of extracting a full json object from within html content so im hoping someone can help me get the right regex to resolve the issue. For example the json im looking to extract looks like this: "taxonomy": {"page":"/products/1/","price":"350.00","country_code":"gb","brand":"apple"}, Im trying to extract the entire "taxonomy" object that is inside a java script function within the html. I have tried preg

Extract JSON object from html using PHP regex

ⅰ亾dé卋堺 提交于 2021-02-07 18:11:28
问题 After reading all related threads i can not find anything that shows regex that is capable of extracting a full json object from within html content so im hoping someone can help me get the right regex to resolve the issue. For example the json im looking to extract looks like this: "taxonomy": {"page":"/products/1/","price":"350.00","country_code":"gb","brand":"apple"}, Im trying to extract the entire "taxonomy" object that is inside a java script function within the html. I have tried preg

Extract JSON object from html using PHP regex

会有一股神秘感。 提交于 2021-02-07 18:08:27
问题 After reading all related threads i can not find anything that shows regex that is capable of extracting a full json object from within html content so im hoping someone can help me get the right regex to resolve the issue. For example the json im looking to extract looks like this: "taxonomy": {"page":"/products/1/","price":"350.00","country_code":"gb","brand":"apple"}, Im trying to extract the entire "taxonomy" object that is inside a java script function within the html. I have tried preg

Parsing pexpect output

女生的网名这么多〃 提交于 2021-02-07 14:15:09
问题 I'm trying to parse in real time the output of a program block-buffered, which means that output is not available until the process ends. What I need is just to parse line by line, filter and manage data from the output, as it could run for hours. I've tried to capture the output with subprocess.Popen(), but yes, as you may guess, Popen can't manage this kind of behavior, it keeps buffering until end of process. from subprocess import Popen, PIPE p = Popen("my noisy stuff ", shell=True,

How to parse a json string response using Delphi

青春壹個敷衍的年華 提交于 2021-02-07 12:32:29
问题 I have a rest server returning the next json string: response:='{"result":["[{\"email\":\"XXX@gmail.com\",\"regid\":\"12312312312312312313213w\"},{\"email\":\"YYYY@gmail.com\",\"regid\":\"AAAAAAA\"}]"]}'; I´d like to parse the response to get a list of all email and regid items. I have tried the next code but I am getting an AV at (TJSONPair(LItem).JsonString.Value='email') Any help will be appreciated. Thanks in advance, Luiz var LResult:TJSONArray; LJsonresponse:TJSONObject; i:integer;

Java - Parsing strings - String.split() versus Pattern & Matcher

℡╲_俬逩灬. 提交于 2021-02-07 12:19:34
问题 Given a String containing a comma delimited list representing a proper noun & category/description pair, what are the pros & cons of using String.split() versus Pattern & Matcher approach to find a particular proper noun and extract the associated category/description pair? The haystack String format will not change. It will always contain comma delimited data in the form of PROPER_NOUN|CATEGORY/DESCRIPTION Common variables for both approaches: String haystack="EARTH|PLANET/COMFORTABLE,MARS

How do I parse a large XML file using Java?

穿精又带淫゛_ 提交于 2021-02-07 10:50:15
问题 I am trying to parse an XML file using Java. The XML file size is 256 kb only. I am using a DOM parser to parse the XML file. How can I parse the large XML file content? Here's the method that parses the file content: public Document parse_a_string(StringBuffer decodedFile) { Document doc1 = null; try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder db = factory.newDocumentBuilder(); InputSource inStream = new InputSource(); // problem here inStream

How to parse string to struct?

好久不见. 提交于 2021-02-07 10:18:26
问题 I want to know if there is any way to convert a string like "5ABBF13A000A01" to the next struct using struct and union method: struct xSensorData2{ unsigned char flags; unsigned int refresh_rate; unsigned int timestamp; }; Data should be: flags = 0x01 (last byte); refresh_rate = 0x000A (two bytes); timestamp = 5ABBF13A (four bytes); I'm thinking in next struct of data: struct xData{ union{ struct{ unsigned char flags:8; unsigned int refresh_rate:16; unsigned int timestamp:32; }; char pcBytes

How to parse string to struct?

橙三吉。 提交于 2021-02-07 10:16:39
问题 I want to know if there is any way to convert a string like "5ABBF13A000A01" to the next struct using struct and union method: struct xSensorData2{ unsigned char flags; unsigned int refresh_rate; unsigned int timestamp; }; Data should be: flags = 0x01 (last byte); refresh_rate = 0x000A (two bytes); timestamp = 5ABBF13A (four bytes); I'm thinking in next struct of data: struct xData{ union{ struct{ unsigned char flags:8; unsigned int refresh_rate:16; unsigned int timestamp:32; }; char pcBytes