Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex dart是否支持perl风格的正则表达式和匹配运算符语法?_Regex_Dart - Fatal编程技术网

Regex dart是否支持perl风格的正则表达式和匹配运算符语法?

Regex dart是否支持perl风格的正则表达式和匹配运算符语法?,regex,dart,Regex,Dart,你能写一些类似于: string =~ /^.s*(.\S+)/; print "First word is '$1'"; dart的语法是什么?还是必须使用原始对象?我不确定dart。但是从这里开始 它的语法似乎与任何其他语言相同。Dart中没有regexp文本和匹配运算符。因此,是的,您必须使用RegExp对象及其同级对象。Dart没有文字RegExp语法: /foo\s*\(bar\)/ 但它确实有原始字符串,您应该使用它们: newregexp(r“foo\s*\(bar\)”;

你能写一些类似于:

string =~ /^.s*(.\S+)/;
print "First word is '$1'";

dart的语法是什么?还是必须使用原始对象?

我不确定dart。但是从这里开始


它的语法似乎与任何其他语言相同。

Dart中没有regexp文本和匹配运算符。因此,是的,您必须使用RegExp对象及其同级对象。

Dart没有文字RegExp语法:

/foo\s*\(bar\)/
但它确实有原始字符串,您应该使用它们:

newregexp(r“foo\s*\(bar\)”;
如果没有原始字符串,您必须将反斜杠加倍,并且(如果您记得这样做的话)您必须:

newregexp(“foo\\s*\\(bar\)”;

谢谢。不幸的是,这是我喜欢perl和ruby的原因之一,而讨厌java。也许将来会有。希望如此。@Jim:很显然,不是很快:正则表达式本身的语法与JavaScript相同(它与Perl和其他Perl派生的风格兼容,但远没有功能丰富)。Jim所问的是语言本身的语法,比如正则表达式文本和匹配运算符,
~=
。我认为PCRE(perl combatible REs)和javascript REs之间有细微的区别,但Dart必须与js兼容。