There're regexp for even DIGIT everywhere: Example:
4
But nowhere regexp for even number: Example :
568
There're regexp for even DIGIT everywhere: Example:
4
But nowhere regexp for even number: Example :
568
Regex is designed to find the pattern in the string, it is not something to find and recognize e.g. (Extract prime number from a string). You should better extract consecutive digits and check for (num % 2 == 0).
But still if you want to stick with regex, the pattern provided in comments above needs a little bit adjustment for you case.
You may try this pattern:
\b(\d+??[02468])\b
EDIT:
I didn't interacted with grep before, but from this doc i found that grep doesn't support all features that is supported for regex engine by other languages.
So i adjusted the pattern based on allowed input, try this pattern:
^([0-9]+[24680]|[02468])$
Tested it here on following inputs:
(Z + (758+1) + X)
(Z + (757+1) + X)
(Z + (123+1) + X)
757
758
123
144
13
14
2
and result is:
758
144
14
2
Hope it helps now!