title: Regex to allow only one punctuation character in Java string
body: <p>I need to parse raw data and allow strings that can contain alphabets and ONLY one punctuation character.</p>
  
  <p>Here is what I have done so far:</p>
  
  <pre><code>public class ProcessRawData {
  
  public static void main(String[] args) {
      String myData = "Australia India# America@!";
      ProcessRawData data = new ProcessRawData();
      data.process(myData);
  
  }
  
  public void process(String rawData) {
      String[] splitData = rawData.split(" ");
      for (String s : splitData) {
          System.out.println("My Data Elements: " + s);
          Pattern pattern = Pattern.compile("^[\\p{Alpha}\\p{Punct}]*$");
          Matcher matcher = pattern.matcher(s);
          if (matcher.matches()) {
              System.out.println("Allowed");
          } else {
              System.out.println("Not allowed");
          }
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>It prints below,</p>
  
  <pre><code>My Data Elements: Australia
  Allowed
  My Data Elements: India#
  Allowed
  My Data Elements: America@!
  Allowed
  </code></pre>
  
  <p>Expected is it should NOT print <strong>America@!</strong> as it contains more than one punctuation character.</p>
  
  <p>I guess I might need to use quantifiers, but not sure where to place them so that it will allow ONLY one punctuation character?</p>
  
  <p>Can someone help?</p>