I am trying to write a regex in Java to get rid of all heading and tailing punctuation characters except for "-" in a String, however keeping the punctuation within words intact. 
- I tried to replace the punctuations with - "",- String regex = "[\\p{Punct}+&&[^-]]";right now, but it will delete the punctuation within word too.
- I also tried to match pattern: - String regex = "[(\\w+\\p{Punct}+\\w+)]";and- Matcher.maches()to match a group, but it gives me null for input- String word = "#(*&wor(&d#)("
I am wondering what is the right way to deal with Regex group matching in this case
Examples:
Input: @)($&word@)($&                   Output: word
Input: @)($)[email protected]#)(*$&$      Output: [email protected]