应用正则表达式时避免创建空白 space

Avoiding to create a blank space when applying regex

我有以下正则表达式:

result = result.replace(/\@.playhouse== 'true' && /g,''); 

上运行
.playground[?(@.playhouse == 'true' && @.IsPoolAvailable=='true')].checked]

在我的输出中,我确实得到了预期的响应,但它在 @ 之前创建了一个 space,如下所示

.playground[?( @.IsPoolAvailable=='true')].checked]

有没有办法只通过 运行 一个正则表达式 exp 来创建 space? 见下文:

.playground[?(@.IsPoolAvailable=='true')].checked]

您需要转义个特殊字符,然后替换:

@\.playhouse\s*==\s*'true'\s+&&\s+

您得到了预期的输出:

Demo