vendredi 31 juillet 2015

What is the equalient of JavaScript's "s.replace(/[^\w]+/g, '-')" in Dart language?

I am trying to get the following working code in JavaScript also working in Dart.

http://ift.tt/1UddDam

var s = "We live, on the # planet    earth";
var results = s.replace(/[^\w]+/g, '-');

document.getElementById("output").innerHTML = results;

Which gives the output

We-live-on-the-planet-earth

I have tried this Dart code

void main() {
    print( "We live, on the # planet    earth".replaceAll("[^\w]+","-"));
}

But the output becomes the same.

What am I missing here?

Aucun commentaire:

Enregistrer un commentaire