【发布时间】:2012-01-23 01:45:14
【问题描述】:
基本上我有一些文件名,中间有一年。我只对获取年份值之前的任何字母或数字感兴趣,但只有字母和数字,而不是逗号、点、下划线等。这可能吗?也许使用正则表达式?
例如:
"A-Good-Life-2010-For-Archive"
"Any.Chararacter_Can+Come.Before!2011-RedundantInfo"
"WhatyouseeIsWhatUget.2012-Not"
"400-Gestures.In1.2000-Communication"
我想要的地方:
"AGoodLife"
"AnyChararacterCanComeBefore"
"WhatyouseeIsWhatUget"
"400GesturesIn1"
我所说的数字是指任何看起来不像年份的数字,即 1 位、2 位、3 位、5 位等等。我只想将 4 位数字识别为年份。
【问题讨论】:
标签: c# .net regex string parsing