Day 123 of 180 Days of Data Viz Learning #jfdi

I’m doing some form of data visualization learning for 180 days because I need to #JFDI.

See post explaining how and why I’m doing this.

Code Learning:

Finding Strings using RegEx

  • var str = “how much wood would a woodchuck chuck”
  • var regex = “/wood/”;
  • if (regex.test(str)) {
  •                 console.log(“We found ‘wood’ in the string!”);
  • }
  • => “We found ‘wood’ in the string!”

To see actual matches

  • var matches = str.match(regex);
  • console.log(matches)
  • => [“wood”]

Find all instances of wood

  • regex = /wood/g;
  • console.log(str.match(regex));
  • => [“wood”, “wood”, “wood”, “wood”]

Extend regular expession match expression that matches everything that starts with wood followed by – or more characters

  • regex = /wood.*?\b/g;
  • console.log(str.match(regex));
  • => [“wood”]



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s