如何在飞镖的大字符串中逃脱许多$符号?

问题描述 投票:0回答:1

我有一个包含Javascript代码的大字符串,我想写入文件。问题是它有许多$符号,编译器将其视为字符串插值。

dart flutter
1个回答
1
投票

在字符串前面使用r表示它是一个原始字符串。

String codeJS =r'''var idMatch = /^#[\w-]*$/,
      classMatch = /^\.[\w-]*$/,
      htmlMatch = /<.+>/,
      singlet = /^\w+$/;''';
© www.soinside.com 2019 - 2024. All rights reserved.