正则表达式编号后跟没有 space 的日期

Regex number followed by date with no space

我有以下几行:

fact prof 45883
factura PROF 46186
FACT.PROF:45126
FACT.PROF.NR.46069
FACTURA PROF. 46296
factura prof.46673
FAC PROFORMA PROF 46876
FACT 44046
FACT 46529
fact proforma nr 46229
FCT PROF:40365
PROF 44283
fact prof 46646
FACT PROF: 45666
fact PROF:45560
Factura proforma : 46059
FCT PROF 45108
fact. proforma nr.46180
FACTURA PROFORMA NR 43864 SI FACTURA PROFORMA NR 43865
PROF 46471
prof nr 42840
PROF. NR.45830
FAC. PROFORMA NR. 46373
fact prof 38518
f prof 45983
factura proforma 46753
factura  prof 46326
f prof 46645
f prof 43723
fact prof.nr 46227
factura proforma 41292
prof 45602
F.45026
FAC. PROFORMA: 43017
FACT 43198
FACT PROF 46284
fact proforma nr 45984
fact prof 46656
fact. nr. 45224
fact PROF:46282
prof 45826
PROFORMA 42801
fact prof 45579
FF 46105
FACTURA PROF 45237
factura proforma 43335
fact nr 43709
FACTURA PROF:46962
Seria PRO nr. 43712
SERIA PRO NR : 43099 
PROF 45515
Factura PROF : 45722
PROFORMA Seria PRO nr. 43051
PROF46215
PROF 45131
PROF460798wheels
proforma 43736
proforma 43642 si 38987
Factura 46690
Fproforma 416477
PROF   45608
factura numar 42995
PROF :43679
PROF:46801
Prof45066
PROF: 45613
Factura 45369
prof 46791
PROF 45198
prof 39970
Prof. 46039
Seria PROF NR 45273
fact. proforma 46446
PROF 46911
prof 45044
PROF: 45674
Proforma 46241
PROF: 43943
prof 43769
prof46611
PROFORMA NR 46635
prof. nr. 45597
PROF42088
FACTURA 44235
PROF 46024 SI 46156
proforma 46219
PROFORMA nr. 4712619.05.2015
Proforma 46333 
PROF  44961
PROF 43941
Prof:45303
prof44895
FACTURA 45199
proforma 46263/12.05.15 
PRPROF:46717

我需要从各个字符串中提取数字。我创建了一个涵盖几乎所有案例的 Reg-ex,但我有 2 个案例无法涵盖:

  1. 第一个是 PROF460798wheels,其中数字与公司名称 (8wheels) 相连

  2. 第二个是PROFORMA nr。 4712619.05.2015,其中数字与日期相连。

有什么方法可以排除这些行或获得正确的数字吗?

到目前为止,这是我的正则表达式:

(?:prof|proforma|F|fact|PRO|factura)\s?\.?\s?(?:nr|numar)?\.?\s?:?\s?(\d+(?!\d\d\.\d{2}\.\d{4}))\s?(?:si)?\s?(\d+)?

部分全文示例:

Decontare -Platitor: COLCERIU LAURA-ELENA; RO20OTPV112004321192RO01-Beneficiar: SC DUMMY SRL; RO96RNCB0040124547320001; CODFISC 16296240-Detalii: /ROC/Fproforma 416477 din 14.05.15//RFB/16
Decontare -Platitor: Aliman Samuel-lucian; RO61INGB2220999904092615-Beneficiar: DUMMY; RO96RNCB4090124247370001-Detalii: /ROC/PROF:46634/RFB/NONE.
Decontare -Platitor: VLAD CAMBURU; RO61INGB2220999904092615-Beneficiar: DUMMY; RO61INGB2220999904092615-Detalii: /ROC/Factura PROF:43751vlad camburu//RFB/1
Decontare -Platitor: CARP COSMIN; RO20OTPV112004321192RO01; CODFISC NA-Beneficiar: DUMMY; RO20OTPV112004323192RO01; CODFISC NA-Detalii: /ROC/PROF:46583                         Abonament servicii sportive dummy  Partener (65676301) 04/05   03/08

如果您唯一需要的是数字,您可以使用以下正则表达式:

/\d+\/\d+\.\d+\.\d+|\d+\.\d+\.\d+|\d+/g

示例:

https://regex101.com/r/bA6vN4/1

编辑

显然您只需要数字的前 5 位数字而不是整个字符串:

/\d{5}/g

https://regex101.com/r/bA6vN4/2

编辑

这个应该做,当它们并排时,它会从数字中删除日期,并考虑到您的特殊 8wheels 情况:

/(?:proforma|PROFORMA|Proforma|factura|FACTURA|Factura|nr|NR|numar|NUMAR|prof|Prof|PROF|fact|FACT|fac|FAC|FCT|si|SI|F)(?:\s?|\.?|:?)*(\d+(?=8wheels|(?:(\d{2}\.\d{2}\.\d{4})))|\d+)/gm

https://regex101.com/r/fJ3sN6/4

(?:prof|proforma|F|fact|PRO|factura)\s*\.?\s*(?:nr|numar)?\.?\s?:?\s?(\d+(?=(?:\d\d\.\d{2}\.\d{4})|\s*$|[a-z]+))

您可以尝试 this.See 演示。

https://regex101.com/r/nM7nT5/8