android字符串获取数字索引,从字符串中提取特定数据(Extract specific data from a string)...

从字符串中提取特定数据(Extract specific data from a string)

我有一个带有描述的长字符串。 我想从字符串中提取一些信息。 但我无法弄明白该怎么做。

这是字符串:

Continental CONTIPREMIUMCONTACT 2 auto / zomerband - 195/55 R15 V85。 Eigenschappen EU bandenlabel:brandstofefficiÃ:ntie:F,grip op nat wegdek:C,geluid:71dB,klasse:C1,geluidsklasse:2 - bij www.tirendo.nl。 Nu geen verzendkosten! Directe瞄准bij een montagepunt naar keuze binnen 1-4 dagen bij u thuis。

我想检索以下结果:

brandstofefficientie = F,grip op natwegdek = C,geluid = 71dB。

我试图使用爆炸提取它,但它并没有真正按照应有的方式工作。

有人可以看看它并帮助我吗?

I have a long string with a description in it. I would like to extract some information from the string. But I can not really figure out how to do it.

This is the string:

Continental CONTIPREMIUMCONTACT 2 auto/zomerband - 195/55 R15 V85. Eigenschappen EU bandenlabel: brandstofefficiëntie: F, grip op nat wegdek: C, geluid: 71dB, klasse: C1, geluidsklasse: 2 - bij www.tirendo.nl. Nu geen verzendkosten! Directe levering bij u thuis of bij een montagepunt naar keuze binnen 1-4 dagen.

I would like to retrieve the following results:

brandstofefficientie = F, grip op natwegdek = C, geluid = 71dB.

I have tried to extract it using explodes but that did not really work the way it should.

Could someone take a look at it and help me please?

原文:https://stackoverflow.com/questions/24672754

更新时间:2020-07-03 12:07

最满意答案

$text='Continental CONTIPREMIUMCONTACT 2 auto/zomerband - 195/55 R15 V85. Eigenschappen EU bandenlabel: brandstofefficiëntie: F, grip op nat wegdek: C, geluid: 71dB, klasse: C1, geluidsklasse: 2 - bij www.tirendo.nl. Nu geen verzendkosten! Directe levering bij u thuis of bij een montagepunt naar keuze binnen 1-4 dagen.=';

$explode=explode(':',$text);

$explode_last=explode(',',$explode[4]);

echo $string=$explode[1]."=".$explode[2]."=".$explode[3]."=".$explode_last[0];

$text='Continental CONTIPREMIUMCONTACT 2 auto/zomerband - 195/55 R15 V85. Eigenschappen EU bandenlabel: brandstofefficiëntie: F, grip op nat wegdek: C, geluid: 71dB, klasse: C1, geluidsklasse: 2 - bij www.tirendo.nl. Nu geen verzendkosten! Directe levering bij u thuis of bij een montagepunt naar keuze binnen 1-4 dagen.=';

$explode=explode(':',$text);

$explode_last=explode(',',$explode[4]);

echo $string=$explode[1]."=".$explode[2]."=".$explode[3]."=".$explode_last[0];

2014-07-10

相关问答

你可以使用re.findall来做到这一点: import re

to_parse = '@10 points = { ( 2.96296 , 0.822213 ) ( 3.7037 , 0.902167 ) } ; L = { 5.20086 } ; P = { 3.14815 3.51852 } ;'

m_list = re.findall(r'(\w+)\s*=\s*{([^}]*)}', to_parse)

measurements = {}

for k,v in m_list:

...

使用这个$showticket['module'] mysql_fetch_assoc返回一个数组,而不仅仅是一个值。 由于你使用的是mysql_fetch_assoc你会得到一个由列名索引的关联数组,因此是['module'] 。 如果你使用mysql_fetch_row你会得到一个数字索引,因此必须使用$showticket[0] 。 但请不要忘记所有的mysql_ *函数都已弃用,将在PHP的未来版本中删除! Use this $showticket['module'] mysql_fetc

...

在您的示例中,您将响应从网站转储到文件,libcURL写入您按原样命中的网页返回的数据,它不会花费重组返回的数据。 您可以通过定义write_data函数来获取内存中的数据,该函数只需要以下格式: size_t write_data(char *ptr, size_t size, size_t nmemb, void *userdata); 在内存中获取数据后,您可以解析它并根据需要对其进行重组。 有关使用write_data函数, 请参见示例 。 对于XML解析,您可以使用此示例代码 In yo

...

ReadAllText将整个文件作为一个字符串返回。 循环一个行数并在每一行上使用子字符串代码会更有意义。 编辑 ReadAllLines是一个静态调用: string[] lines = System.IO.File.ReadAllLines(fileName);

或者,使用流一次读取一行: var sr = new StreamReader(fileStream);

while (!sr.EndOfStream)

{

var line = sr.ReadLine();

// .. p

...

我将XmlDocumnet更改为XDocument,因此我可以使用Xml Linq。 我也用于测试使用StringReader来读取字符串而不是从文件中读取。 您可以将代码转换回原始的File.ReadAlltext。 using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Xml;

using System.Xml.Linq;

using System.I

...

根据我的经验,当从csv读取时,你的dict列是字符串,所以我们需要首先使用来自ast literal_eval将其转换回来,然后我们需要以下步骤 s=df.rate.apply(pd.Series).set_index('id').stack().apply(pd.Series)

s

Out[289]:

interval pay_rate

id

101 win 21.0 0.239

1892 w

...

尝试这个: getIntent().getExtras().get("android.intent.extra.STREAM")

getIntent().getClipData()

在我的设备上,这个对象是: getIntent().getExtras().get("android.intent.extra.STREAM") = {android.net.Uri$HierarchicalUri@830027572808}"content://com.android.contacts/conta

...

要获得第一个数字后面的第一个数字(我们可以使用.*\((\d+) 。然后得到/后面的第一个数字,我们可以使用/(\d+)\) 。然后得到第一个数字在“链接”之后: [lL]ink (\d+) 。我们将这些放在一起得到 ^.*\((\d+)/(\d+)\).*[lL]ink (\d+)

这三个数字将分为三组 To get the first number after the first (, we can use .*\((\d+). Then to get the first number af

...

如果数据总是在两个哈希之间,请尝试这样的正则表达式:( (?i)#.*your_match.*#其中your_match将是UK , label , 1_等。 然后将此表达式与Pattern和Matcher类结合使用。 如果你想匹配多个字符串,你需要通过使用环视方法和不情愿的修饰符来排除匹配中的哈希值,例如(?i)(?<=#).*?label.*?(?=#) 。 短暂细分: (?i)会使表达式不区分大小写 (?<=#)是一个积极的后瞻,即匹配必须在哈希之前(但不包括哈希) .*? 匹配任何字符序列

...

$text='Continental CONTIPREMIUMCONTACT 2 auto/zomerband - 195/55 R15 V85. Eigenschappen EU bandenlabel: brandstofefficiëntie: F, grip op nat wegdek: C, geluid: 71dB, klasse: C1, geluidsklasse: 2 - bij www.tirendo.nl. Nu geen verzendkosten! Directe le

...

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值