welcome to SO.
If you want to "match a string ending with something", you have to use $
in your regex (and don't forget to quote the .
, it's a special character in regexen):
"^[^ce]\\.mob$"
(otherwise you'll match biloximob5
, for instance).
If your strings may be different than the five you have shown, maybe you'll have to be more generic:
"^([^ce]|..+)?\\.mob$"
for instance, matches .mob
, elefante.mob
, but does not match .mobi
or e.mob
...
May I suggest a regex-trying tool like regexr? It might be a good idea so you can train in the use of regexen.
Update: don't forget to quote the backslashes when you go back from perl/regexr to c++....