How can I remove all leading and trailing punctuation?

前端 未结 3 563
不思量自难忘°
不思量自难忘° 2020-12-11 17:30

I want to remove all the leading and trailing punctuation in a string. How can I do this?

Basically, I want to preserve punctuation in between words, and I need to r

3条回答
  •  北荒
    北荒 (楼主)
    2020-12-11 17:54

    Use this tutorial on patterns. You have to create a regex that matches string starting with alphabet or number and ending with alphabet or number and do inputString.matches("regex")

提交回复
热议问题