正则表达式匹配外部尖括号

时间:2014-02-10 13:35:27

标签: php regex

我需要更换尖括号外的所有内容

示例 输入字符串:

hello <how> are you <I'm fine> thanks. <what "about" you>, I'm fine as well thank you. 

输出字符串:

* <how> * * <I'm fine> *. <what "about" you>, * * * * * *.

1 个答案:

答案 0 :(得分:4)

由于语言/工具未知,您可以尝试:

search: ((?:<[^>]*>|[.,\s])*)[^\s,.<]+((?:<[^>]*>|[.,\s])*)
replace: $1*$2