Regex 如何从这个旋转语法代码中删除星号?

Regex 如何从这个旋转语法代码中删除星号?,regex,Regex,这是我的代码,它是一个文本微调器(同义词) 有一个regex请求这样的括号 {*spin1|spin2|spin3*} 下面是上面代码片段中的正则表达式 if (preg_match_all('/({\*)(.*?)(\*})/', $customContent, $result)) $customContent = preg_replace('/(\{\*)(.*?)(\*\})/', '{#'.$index.'#}', $customContent, 1); 我想删除

这是我的代码,它是一个文本微调器(同义词)

有一个regex请求这样的括号

   {*spin1|spin2|spin3*}
下面是上面代码片段中的正则表达式

   if (preg_match_all('/({\*)(.*?)(\*})/', $customContent, $result))

   $customContent = preg_replace('/(\{\*)(.*?)(\*\})/', '{#'.$index.'#}', $customContent, 1);
我想删除*格式以允许{spin1 | spin2 | spin3}与大多数微调器更兼容

我在网上找到了一些正则表达式 我试图从两个正则表达式中删除*但没有结果


非常感谢您的帮助

删除
\*
而不仅仅是
*
–Lucas Trzesniewski

您可以尝试
preg\u replace('/{*(.*?\*}/','{$1}',$customContent))删除
\*
而不是只删除
*
你的技巧成功了:)
   if (preg_match_all('/({\*)(.*?)(\*})/', $customContent, $result))

   $customContent = preg_replace('/(\{\*)(.*?)(\*\})/', '{#'.$index.'#}', $customContent, 1);