我的案文如下:
He found a &#compelling reason to get& out of bed in the #morning. | For reasons unknown, #most people &feel #compelled to& answer a ringing phone. | There's was no #logical basis for the choice since it was determined solely &on #intuition&我想得到的是前面有#符号的所有单词,周围都是&符号:#令人信服的,#强制的,#直觉的(不是#早晨,#多数和#逻辑,它们没有被&符号包围)。
如能提供任何帮助,将不胜感激:)
发布于 2021-03-25 05:48:17
你能试一下以下几种方法吗?
&[^&#]*(#\w+)[^&]*&&[^&#]*与&匹配,除&和#外,后面跟着任何字符。(#\w+)匹配一个带有#符号的单词,匹配的子字符串在组1中捕获。[^&]*&匹配除&以外的任何字符的&。虽然您没有指定regex风格,但它将适用于许多平台。
https://stackoverflow.com/questions/66791971
复制相似问题