Hi,
Here is my macro...
I search the regex document, and now I know that regex "or" is "|
", "and" is "&&
".
But – the "|
" is working and the "&&
" is not working.
Did I type the wrong regex symbol?
Hi,
Here is my macro...
I search the regex document, and now I know that regex "or" is "|
", "and" is "&&
".
But – the "|
" is working and the "&&
" is not working.
Did I type the wrong regex symbol?
You could still use RegEx condition. It then should be "matches" rather than "contains".
If eco
always supposed to come before pdf
(I assume pdf
is the file extension), then you could use something like below:
I've never seen a logical &&
used in a regex -- do you have an example?
As well as @martin's suggestions you could investigate "lookaheads". And if you want to do "has eco
and pdf
in any order" in one operation then (eco.*pdf|pdf.*eco)
should do the trick.
He wouldn’t even need the capture group parenthesis unless he needed to act on the found match(es).
True -- but I've got into the (possibly bad?) habit of parenthesising "match groups" even when unnecessary. I find it easier to see what's going on, easier to expand later, and my future self will be grateful when I next look at that action.
I do that too most of the time, just for legibility’s sake, but I use the non capture group (?:)
… why? Because I’m crazy probably.
I absolutely get that!
But – I wouldn't put it out there for someone who's clearly a newbie – at least not without an explanation.
You'll see that's something different -- it's finding the intersection of two character sets so you can use "things that are in both sets" as the match expression.
You can't use that in the way you want because the regex would be "if this characters is e
AND p
, and the next is c
AND d
..." -- and, obviously, a the character you are testing can't be both e
and p
at the same time.