Ignore my philosophies
Posted: Fri Jul 26, 2013 6:03 am
So I am sitting here trying to devise an expression to that will reliably match file extensions and only file extensions without having to type them all out.
(i.e. ^.*?\.(reg|ex|can|suk) )
When devising expressions that are not simple I always remind myself that regex is greedy.
Regex wants to take everything and it doesn't give two f..ks that you don't want it to take everything.
Doesn't care what you think or how you feel about anything.
It will only laugh (if it could) when you get frustrated because it isn't being logical or rational.
It is a matter of trying to make it do what you want (or trick it) and you often still lose.
Then it dawned on me, regex is Friend of the Court.
(That's the punch line. Go back about your business. Nothing more to see here.)
(i.e. ^.*?\.(reg|ex|can|suk) )
When devising expressions that are not simple I always remind myself that regex is greedy.
Regex wants to take everything and it doesn't give two f..ks that you don't want it to take everything.
Doesn't care what you think or how you feel about anything.
It will only laugh (if it could) when you get frustrated because it isn't being logical or rational.
It is a matter of trying to make it do what you want (or trick it) and you often still lose.
Then it dawned on me, regex is Friend of the Court.
(That's the punch line. Go back about your business. Nothing more to see here.)