I've found the regex to locate all hyphenated and "apostrophied" words:
(?=\S*['-])([a-zA-Z'-]+)
Examples: l'Equipe and action-oriented
I'm not sure how to utilize this information to get what I want after a bit of searching...
Try this regex
(?<=\b)[,.'-:"]+(?=\s|$)|"
Demo: https://regex101.com/r/mDhl17/1/
Here are some details
Positive Lookbehind
with a word boundary token in order to exclude any punctuation that has letters before it. [,.'-:"]+
. You can add to the list whatever you prefer to catch. (?=\\s|$)
. " "
, we want to catch them whenever they are there, so I added the OR |
condition at the end.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.