简体   繁体   中英

Regular Expression. remove dashes.

I have a large array of names. The software names them really long and doesn't have a way to override it. I want to just get out the file name I need. I've been using regex because it feels like it should be able to get just this part of the string. Any help would be great I've spent a day with no luck.

Here is the output.

UCM - S - Loading 1H_lester.virata.sfw811 - Sheet - 1H-S11-00 - LEVEL 01 FOUNDATION PLAN

UCM - S - Loading 1H_lester.virata.sfw811 - Sheet - 1H-S11-00A - LEVEL 01 REINFORCEMENT PLAN

UCM - S - Loading 1H_lester.virata.sfw811 - Sheet - 1H-S11-01A - LEVEL 02 ROOF REINFORCEMENT PLAN

I want to return: 1HS1100 1HS1100A 1HS1101A

您可以使用\\w+-[\\w-]+example )捕获带连字符的字符串,然后使用替换 / 替换命令处理它们以将'-'替换为''

"^[^\\d]+(\\d\\w)_\\w+.\\w+.(\\w+)[^\\d]+(\\w+)-(\\w+)-(\\w+)[^\\d]+(\\d+)"

Just combine all the matches from the above regular expression and that should do it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM