I need to find one of two words, “nominal” or “arrété” (yes, because i use putty!)
normaly it’s two results, sometimes it might be this :
login as: server
server@IP's password:
Last login: Fri Jun 7 09:43:34 2019 from IP
[server@app-test-2 ~]$ rcserver status
Etat de server : mode nominal
Or :
login as: server
server@IP's password:
Last login: Fri Jun 7 09:43:34 2019 from IP
[server@app-test-2 ~]$ rcserver status
Etat de server : arrêté
I used this :
((?:^|\W)nominal(?:$|\W)|(?:^|\W)arrété(?:$|\W))
PS: the result must be only “nominal” or “arrété” not both of them, since it depens on the if it’s running or not.
Hey man if you want to find both, you need to have the global flag. Ex: /((?:^|\W)mode nominal(?:$|\W)|(?:^|\W)arr▒t▒(?:$|\W))/g
the last letter g is the global flag. I wonder if you already tried it?
here is my code, and it works. I am not sure what is the case here. May be the online regex testing is not correct?
let pattern = /((?:^|\W)mode nominal(?:$|\W)|(?:^|\W)arrite(?:$|\W))/g;
let str = `login as: server
server@IP's password:
Last login: Fri Jun 7 09:43:34 2019 from IP
[server@app-test-2 ~]$ rcserver status
Etat de server : mode nominal
login as: server
server@IP's password:
Last login: Fri Jun 7 09:43:34 2019 from IP
[server@app-test-2 ~]$ rcserver status
Etat de server : arrite
`;
let a = str.match(pattern);
console.log(a);
When I read your question (in chrome mobile) “arrite” shows up oddly with two special characters instead of the last two vowels. So it’s worth checking if your problems are to do with encoding, either in your code or whatever tool you’re using to test your regex.
Oh, i see what you mean, infact i’m not coding, i’m using UiPath, so i’m trying a regex code that works on it, that’s why. For the group, i don’t know how to use it on the UiPath.