【发布时间】:2017-05-29 15:11:22
【问题描述】:
以下是我需要在存储为文本的请求中匹配的内容示例:
[{"id":"896","name":"TinyAuras","author_id":"654","author":"Kurisu","githubFolder":"https://github.com/xKurisu/TinyAuras/blob/master/TinyAuras.csproj","count":9,"countByChampion":{"":9,"total":9 },"description":"(Beta) Aura/Buff/Debuff Tracker","udate":"1451971516","createdDays":375,"image":"https://cdn.joduska.me/forum/uploads /assemblydb/image-default.jpg","strudate":"2016-07-22 19:40","champions":null,"forum_link":"165574","assembly_compiles":true,"voted":false ,"voted_champions":[]},
我想选择该链接直到此处停止(基本上是 github 文件夹,而不是实际的 csproj)。
我有一个包含数千个链接的文件,我正在尝试提取所有这些链接并将它们放入一个文本文件中。
这是我目前对 perl 正则表达式的了解:
(?<=githubFolder":").*(?=\/.+\.csproj") 但最终在第一场比赛后选择的数量超出了我的需要。有什么建议吗?
问题是,我想要 this.csproj 之前的所有内容。
所以在我的示例中,我想提取: https://github.com/xKurisu/TinyAuras/blob/master/
【问题讨论】:
-
请分享更多示例链接,以便识别模式。
-
我添加了工作正则表达式模式来抓取 url,只需要弄清楚如何只选择 this.csproj
-
sed 's/\(^.*\)[.]csproj["]$/\1/' file > newfile怎么样? (如果末尾没有双引号,则可以删除["])您可以在\(之前添加"githubFolder":",如果需要删除^"githubFolder":" -
抓太多了,我会用更大的例子更新帖子。
-
哦...现在我明白了。这不适用于更新...