powershell - Regex to find space before a month name or abbreviation -
in powershell script i'm trying write regex find space before month name or abbreviation (e.g. jan, january, feb, february, etc.). i'm using drive -replace operator. i've constructed regex works, finds space before works jane, marcus, etc. find space before exact words such jan, january, mar, march, etc. ideas?
[ ](?=jan|(?:uary)?|feb(?:ruary)?|mar(?:ch)?|apr(?:il)?|may|jun(?:e)?|jul(?:y)?|aug(?:ust)?|sep(?:tember)?|oct(?:ober)?|nov(?:ember)?|dec(?:ember)?)
thanks in advance help.
you've got of right. missing part end-of-the-word anchor \b
, prevents matching prefixes of longer words:
\s(?=(?:jan(?:uary)?|feb(?:ruary)?|mar(?:ch)?|apr(?:il)?|may|jun(?:e)?|jul(?:y)?|aug(?:ust)?|sep(?:tember)?|oct(?:ober)?|nov(?:ember)?|dec(?:ember)?)\b)
note: replaces [ ]
\s
, matches tabs , newlines.
Comments
Post a Comment