Question: As nagios user, I cannot execute systemctl. Tracking it down to pkexec, I get :

```
-sh-4.2$ pkexec systemctl reload nagios
==== AUTHENTICATING FOR org.freedesktop.policykit.exec ===
Authentication is needed to run `/bin/systemctl' as the super user

```

However, I have a very, very lenient polkit rule (it is a NOT a production system)

```
polkit.addRule(function(action, subject) {
    if (action.id == "org.freedesktop.systemd1.manage-units") {
        var verb = action.lookup("verb");
        if (verb == "start" || verb == "stop" || verb == "restart" || verb == "reload") {
            return polkit.Result.YES;
        }
    }
});

```

I double check it is compiled when restarting polkit.service
What is the problem ?

```
OS : RHEL7
Sytemd version 219
PolKit version : 0.112

```

Thanks,

Xavier

Answer: 
```
    public static void main(String[] args) throws Exception {
        File file = new File("chat.txt");
        String patternString = "\\+\\d{2,3}(?: \\d{3,4}){2,3}";
        Pattern pattern = Pattern.compile(patternString);
        try (Scanner content = new Scanner(file)) {
            while (content.hasNext()) {
                String line = content.nextLine();
                Matcher matcher = pattern.matcher(line);
                if (matcher.find()) {
                    System.out.println(matcher.group());
                }
            }
        }
    }

```

is one way of doing it. Non-capturing group, with repetitions.
To find the string use:

```
if(matcher.find()){
    String phone = matcher.group(1); 
    // output or write in a new file
}

```

An example regex which should work is:

```
^\+[1-9]{1}[0-9]{3,14}$

```