Conditional Renderings with JavaScript Regex

前端 未结 2 1979
自闭症患者
自闭症患者 2021-01-15 10:03

I need to match on a string such as this:

\'if Country equals \"United States\" then Show\'

I\'m working with the Webforms for Marketers Module

2条回答
  •  情书的邮戳
    2021-01-15 10:31

    Just use "; no need to escape it.

    Also, you're apparently trying to match the " without first matching the equals, so it won't match any of your test cases.

    /^if\s+(\d*|\w*)\s+".*$/.test("if abc \"xyz\"") // ==> true
    /^if\s+(\d*|\w*)\s+".*$/.test("if abc equals \"xyz\"") // ==> false
    

提交回复
热议问题