从以下字符串中提取数据的正则表达式是什么

What will be the regex for extracting the data from following string

我必须编写一个应用程序,它必须提取前 16 位数字 (0989563275315984)、crtexttiff1.0_xcvb-uploadtheDoc-hkl56895-20990415-05:11:24,897-2013027676

0989563275315984-1.0_xcvb-uploadtheDoc-hkl56895-20990415-05:11:24,897-2013027676-crtext-tiff.wrk

到目前为止我想出的正则表达式是这样的:

([0-9a-zA-Z]+)-(\d\.\d[_0-9a-zA-Z]*)-([0-9a-zA-Z]+).([a-zA-Z]+).([0-9]?).*

有没有办法为这个要求写一个正则表达式。提前致谢。

简单!

^(\d{16})-(.+)-(\w+)-(\w+)\.wrk$

演示: https://regex101.com/r/aK5fY9/3

解释:

秘密^$^ 是字符串锚点的开头,$ 是字符串锚点的结尾。 {16} 角色出现的次数。

试试这个

(\d{16})-(.*?)-(\w+)-(\w+)\.

Regex demo

解释:
( … ): 捕获组 sample
\:转义特殊字符sample
.:除换行符外的任意字符sample
*:零次或多次sample
?:一次或none sample
\w: "word character": ASCII 字母、数字或下划线 sample
+:一个或多个 sample