简体   繁体   中英

Regex to match two words in a string

I have a string

"13572_BranchInformationReport_2012-06-28.zip","13572_BranchInformationReport_2012-06-28.zip",0,"184296"," Jun 28 1:30","/icons/default.gif"

What could be the Regex If i want to extract Jun 28 from this string using c#.

This seems to be a CSV record. If so I suggest to use standard string.Split() function to extract the single components and extract the date by trimming the token containing the date, regex should be used if there is no simpler way to achieve what you need.

如果您知道月份名称缩写的格式,则可以使用以下格式:

@"((Jan|Feb|Mar|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\\s[0-9]+)(?<!\\s)"

Assuming that the structure of the string is always the same:

@".*\"".\"".*\"".\""([\w]+ [\w]+) .*\"".\"".*"

and then us the

match.Groups[1]

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