Excising name parts WITH exceptions

A swapping-ground for Regular Expression syntax

Excising name parts WITH exceptions

Postby GrantM » Mon Feb 05, 2018 10:25 am

I have a series of files that I used the old "(tag) in the name" method for helping me sort and then later find the files. NOW, I have an indexer for the text and it makes more sense to use it than my old-fashioned way of doing things. However, there are a few caveats (aren't there always?) My first try at the regex for the find (the replacement in all cases is simply nothing, I just want to remove the portion of the file name) went like this:

Code: Select all
\s\([A-Z,a-z)(.*)MajorSuit\).doc[x]$


The intention was to match an ending section of the name of these doc(x) files was to find a space and then an opening bracket, followed by however many characters there were until it meets MajorSuit) at the end of the file name. I then have to do regex's for MinorSuit, NT, etc. An example of a fit for the regex I was trying to create for a positive was "blablabla (Bill variation for forcing 1NT over MajorSuit).docx)" or "blablabla (Ronny's forcing 1NT over MajorSuit).doc"

BUT I DO NOT want to match "blablabla (1981 Vanderbilt card Section MajorSuit).doc" as I want to keep specific notes for tournaments for quick comparing of differences. My mind is less able then it used to be and a quick run through a merge against my personal general notes gives me discussion points with old partners renewing for a game or a tournament. I hope I'm not being too obtuse with this Bridge jargon. But I have accumulated a LOT of documentation over the fourty plus years of playing Bridge at a decent level.

For bonus points, a regex primer on WHY your solution works and a blue ribbon if I can get explained to me how to replace 'MajorSuit' with 'Majors' in the same solution. (heck, I'd even be happy with M and then m for the minor suits and ultimately, just chopping out the whole bracket that's positive is very conducive to reducing name-lengths from toooooo much to just enough).

TIA
GrantM
 
Posts: 1
Joined: Fri Jan 26, 2018 12:42 pm

Return to Regular Expressions