我有一个包含Javascript代码的大字符串,我想写入文件。问题是它有许多$符号,编译器将其视为字符串插值。
在字符串前面使用r表示它是一个原始字符串。
String codeJS =r'''var idMatch = /^#[\w-]*$/, classMatch = /^\.[\w-]*$/, htmlMatch = /<.+>/, singlet = /^\w+$/;''';