I have a requirement to ensure that the string has only alphanumeric or a set of characters like + ( ) , ' . - =
I tried like

```
    String regex = "([a-zA-Z0-9]+)|([\\'|\\()|\\+|\\,|\\-|\\.|\\="]+)";
    System.out.println("Regex : " + regex);

    Pattern pattern = Pattern.compile(regex);
    Matcher matcher = pattern.matcher(str);

    if (matcher.matches()) {
        System.out.println("Match");
    } else {
        System.out.println("Not Matching");
    }

```

Bt it is not working, Can anyone help me please

Thanks in advance