天道酬勤,学无止境

string-parsing

Getting domain in AS3

I know how to get the URL of the page, but how can I extract simply the domain and the domain alone? It must return the same value with or without www, and it must also return the same value regardless of file, with or without trailing slash, etc. So www.domain.com would return domain.com, and domain.com/index.php would return the same as well. Is this possible? If so, is there a way to do it without calling ExternalInterface.call('window.location.href.toString')? Thank you for the help!

2022-01-17 07:17:38    分类:问答    flash   actionscript-3   dns   string-parsing

Javascript - 值存在,然后消失,然后再次出现?(Javascript - value exists, then disappears, then appears again?)

问题 这让我发疯了。 我也无法通过 Firebug 逐步解决。 有人可以解释一下这里发生了什么吗? 基本上我有一个传入的文本文件,其中每一行都包含一个管道分隔的记录。 我将它们拆分为一个字符串数组,以供以后在自动完成文本框中使用。 代码如下: <script type="text/javascript"> $(function () { var rawData = new Array(); $.get("/sample.txt", function (data) { var raw = data.split('\n'); for (var i = 0; i < raw.length; i++) { rawData.push(raw[i].split('|')); }; alert(rawData); // 1st sanity check } ); alert(rawData); // 2nd sanity check alert(rawData); // 3rd sanity check 出于某种原因,第一次健全性检查工作正常 - 它显示了我所期望的所有数据。 第二个显示 rawData 为空......但第三个再次显示所有数据。 删除第 1 次健全性检查不会影响第 2 次和第 3 次。 这怎么可能? 为什么会这样? 这真让我抓狂。 回答1 您忘记了 get()

2022-01-16 18:21:11    分类:技术分享    javascript   jquery   multidimensional-array   scope   string-parsing

C# - 如何解析文本文件(空格分隔的数字)?(C# - How to parse text file (space delimited numbers)?)

问题 给定一个由空格分隔的数据文件, 10 10 10 10 222 331 2 3 3 4 45 4 2 2 4 如何读取此文件并加载到数组中 谢谢 回答1 var fileContent = File.ReadAllText(fileName); var array = fileContent.Split((string[])null, StringSplitOptions.RemoveEmptyEntries); 如果你只有数字并且需要一个 int 列表,你可以这样做: var numbers = array.Select(arg => int.Parse(arg)).ToList(); 回答2 这取决于您想要的数组类型。 如果要将所有内容展平为一维数组,请使用 Alex Aza 的答案,否则,如果您想要一个映射到文本文件中的行和元素的二维数组: var array = File.ReadAllLines(filename) .Select(line => line.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)) .Where(line => !string.IsNullOrWhiteSpace(line)) // Use this to filter blank lines. .Select

2022-01-16 10:12:37    分类:技术分享    c#   .net   file   string   string-parsing

C# - How to parse text file (space delimited numbers)?

Given a data file delimited by space, 10 10 10 10 222 331 2 3 3 4 45 4 2 2 4 How to read this file and load into an Array Thank you

2022-01-15 20:42:58    分类:问答    c#   .net   file   string   string-parsing

如何处理来自 NBA.com 的数据?(How to work with data from NBA.com?)

问题 我找到了 Greg Reda 的关于从 nba.com 抓取 HTML 的博文: http://www.gregreda.com/2015/02/15/web-scraping-finding-the-api/ 我尝试使用他在那里编写的代码: import requests import json url = 'http://stats.nba.com/stats/leaguedashteamshotlocations?Conference=&DateFr' + \ 'om=&DateTo=&DistanceRange=By+Zone&Division=&GameScope=&GameSegment=&LastN' + \ 'Games=0&LeagueID=00&Location=&MeasureType=Opponent&Month=0&OpponentTeamID' + \ '=0&Outcome=&PORound=0&PaceAdjust=N&PerMode=PerGame&Period=0&PlayerExperien' + \ 'ce=&PlayerPosition=&PlusMinus=N&Rank=N&Season=2014-15&SeasonSegment=&Seas' + \ 'onType=Regular+Season&ShotClockRange=

2022-01-13 02:52:12    分类:技术分享    python   html   web-scraping   text-processing   string-parsing

Javascript - value exists, then disappears, then appears again?

This is driving me nuts. I can't work it out stepping through with Firebug either. Can someone please explain what is going on here? Basically I have an incoming text file where each line contains a pipe-delimited record. I'm splitting these into an array of array of string for later use in an autocomplete textbox. The code is as follows: <script type="text/javascript"> $(function () { var rawData = new Array(); $.get("/sample.txt", function (data) { var raw = data.split('\n'); for (var i = 0; i < raw.length; i++) { rawData.push(raw[i].split('|')); }; alert(rawData); // 1st sanity check } )

2022-01-11 15:27:53    分类:问答    javascript   jquery   multidimensional-array   scope   string-parsing

How to work with data from NBA.com?

I found Greg Reda's blog post about scraping HTML from nba.com: http://www.gregreda.com/2015/02/15/web-scraping-finding-the-api/ I tried to work with the code he wrote there: import requests import json url = 'http://stats.nba.com/stats/leaguedashteamshotlocations?Conference=&DateFr' + \ 'om=&DateTo=&DistanceRange=By+Zone&Division=&GameScope=&GameSegment=&LastN' + \ 'Games=0&LeagueID=00&Location=&MeasureType=Opponent&Month=0&OpponentTeamID' + \ '=0&Outcome=&PORound=0&PaceAdjust=N&PerMode=PerGame&Period=0&PlayerExperien' + \ 'ce=&PlayerPosition=&PlusMinus=N&Rank=N&Season=2014-15&SeasonSegment=

2022-01-11 10:53:45    分类:问答    python   html   web-scraping   text-processing   string-parsing

Java中的sscanf等价物[重复](sscanf equivalent in Java [duplicate])

问题 这个问题在这里已经有了答案: 9 年前关闭。 可能重复: 使用已知模式从字符串中解析值的 sscanf 的 Java 等效项是什么? 我对 Java 还很陌生,但是看到 sscanf 函数有多么有用,我想知道 Java 中是否有等效函数。 我有很多格式化的字符串(即,为我的目的编写脚本语言),所以正则表达式在这里是多余的。 回答1 Scanner scanner = new Scanner ("2 A text 3 4"); scanner.nextInt (); // 2 scanner.next (); // A scanner.next (); // text scanner.nextInt (); // 3 scanner.nextInt (); // 4 // and so on. 这是 Scanner 类的官方文档。

2022-01-11 10:40:11    分类:技术分享    java   string-parsing   scanf

Parsing a Connection String

Is there a standard library or code snippet to get a value with a connection string like this? string connstr = "DataServiceUrl=http://localhost/foo;" + "RemoteServerConnection={server=http://localhost/foo2;interface=0.0.0.0;};" + "publisherport=1234;StatisticsURL=http://localhost/foo3"; The whole inner connection property is kind of throwing this in a loop. I'd like to get specific values based on a key. Here was the answer posted by John I used: System.Data.Odbc.OdbcConnectionStringBuilder builder = new System.Data.Odbc.OdbcConnectionStringBuilder(); builder.ConnectionString = this

2022-01-10 03:27:03    分类:问答    c#   connection-string   string-parsing

sscanf equivalent in Java [duplicate]

This question already has answers here: Closed 9 years ago. Possible Duplicate: what is the Java equivalent of sscanf for parsing values from a string using a known pattern? I'm pretty new to Java, but seeing how useful the sscanf function is, I wonder if there is an equivalent in Java. I've got many pretty much formatted strings (namely, writing scripting language for my purposes), so regular expressions are overkill here.

2022-01-09 09:18:51    分类:问答    java   string-parsing   scanf