Reputation: 231
Can you write anything like:
string =~ /^.s*(.\S+)/;
print "First word is '$1'";
What is the syntax in dart? Or must one use the raw objects?
Upvotes: 2
Views: 727
Reputation: 1550
I am not sure about dart. But from here
http://www.dartlang.org/docs/dart-up-and-running/ch03.html#ch03-strings-and-regular-expressions
it looks like the syntax is same as any other language.
Upvotes: 1
Reputation: 650
Dart doesn't have literal regexp syntax:
/foo\s*\(bar\)/
But it does have raw strings, and you should use them:
new RegExp(r"foo\s*\(bar\)");
without raw strings, you would have to double the backslashes and (if you remembered to do that) you would have:
new RegExp("foo\\s*\\(bar\\)");
Upvotes: 1
Reputation: 6597
There are no regexp literals and match operators in Dart. So yes, you have to use the RegExp object and its siblings.
Upvotes: 3