how to get the match strings(either special characters(like +-=.etc) or string(a-z letters) on the given values.
<p>i have here a pure java code, this one gives me an output of "Special Characters are: java.util.regex.Matcher[pattern=[\p{Punct}&amp;&amp;[^_]]+ region=0,8 lastmatch=&amp;&amp;=+-]" as i compile &amp; run, but i want only to have an output of  "Special Characters are:  &amp;&amp;=+-" based on my given value. and also the same with  strings as "strings are: sam" but dont know how to do this, pls help... i used netbeans ide</p>

<pre><code>     import java.util.regex.Matcher;
     import java.util.regex.Pattern;

     class SubstringsOfAString
     {
      public static void main(String args[])
         {

        String sample = "sam&amp;&amp;=+-";
        Pattern p = Pattern.compile("[\\p{Punct}&amp;&amp;[^_]]+");
         Matcher m = p.matcher(sample);

       boolean b = m.find();

       if(b == true)
       {
         System.out.println("Special Characters are: " + m );

         }

       else {
      System.out.println("Nothing" );
       }

            }
     }
</code></pre>
