逻辑上是不可能获取这个特殊的字符串? [英] Logically Impossible to fetch this particular string.?

查看:116
本文介绍了逻辑上是不可能获取这个特殊的字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有3个字符串这是随机的,有些看起来像这样

I have 3 strings which are random and look somewhat like this

1) ENTL.COMPENSATION REM      REVERSE PAYMENT COUPON ON ISIN //IT0004889033  IN A TRIPARTY //TRANSACTION WITH 95724
2) 01P ISIN DE000A1H36U5 QTY 44527000, //C/P 19696
3) COUPON ISIN XS0820547742 QTY 466750,

现在的期望是什么是获取的值的 IT0004889033 DE000A1H36U5 XS0820547742 的。如果你观察3串,这3个预期值来了ISIN后仪式。因此,我们可以采取ISIN作为参考,然后ISIN后获取的值。但是,这并不是什么是需要它似乎。我们不应该采取一些值作为参考获取价值。

Now what is expected is to fetch the values IT0004889033 or DE000A1H36U5 or XS0820547742. If you observe the 3 strings, these 3 expected values come rite after the ISIN. So we can take isin as a reference and then fetch the values after ISIN. But that is not what is required it seems. We should not fetch the value by taking some value as a reference.

由于期望值的 IT0004889033 的这是一个12数字字符我有信息;第2个字符是字母,接下来的9是字母,最后一个是其中一位。只是这些信息是有可能做一个通配符搜索什么,并获取该12位值。?

Since the expected value is IT0004889033 which is a 12 digit character the information I have is; first 2 characters are alphabets, next 9 are alphanumeric and the last one is a digit. Just with this information is it possible to do a wildcard search or something and fetch this 12 digit value.?

我完全失去了在这一个逻辑。

I'm totally lost on this one logically.

推荐答案

您提到的 ISIN 不应被用来作为参考。因此,可以肯定的唯一的事情就是要找到字符串以2个字母,后面9个字母和/或数字开始,以数字结束。

You mentioned that ISIN should not be used as a reference. Therefore, the only thing for sure is that the string to be found starts with 2 letters, followed by 9 letters and/or numbers, and ends with a number.

我救了你的例子文字的 TMP 的,跑到下面的 egrep的的命令似乎为我工作:

I saved your example text as tmp, and ran the following egrep command... seems to work for me:

jim@debian:~/tmp$ egrep -o "[a-zA-Z]{2}[a-zA-Z0-9]{9}[0-9]{1}" tmp
IT0004889033
DE000A1H36U5
XS0820547742

上面的解决方案更<青霉>正确的比previous那些,因为它需要字符的固定量的筛选结果。只有12个字符的字符串将上述code返回。

The above solution is more correct than the previous ones because it takes a fixed amount of characters to filter the results. Only 12-character strings will be returned by the above code.

我希望这有助于!

这篇关于逻辑上是不可能获取这个特殊的字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆