Tag: regular expressions

Read More
Create a Request Header Parser Microservice with Node.js

Create a Request Header Parser Microservice in Node.js

This time, we are going to be creating a request header parser microservice in Node.js. Keep in mind that I’ll be using a set-up similar to  that used by the previous two tutorials; for those who have not read them, that means that we’ll be using Express, and code our app using ECMAScript 6 thanks to Babel.

Feel free to go though the creation of a simple Express app post, as well as the set-up for using ECMAScript 6 within your node app.

FCC Bonfire Series 129: Spinal Tab Case

Hello campers of young and old, today, we are going to be converting strings to spinal-tab-case. If you did not know about spinal-tab-case, well, you do now. You just-saw-it-twic… thrice!

Spinal case simply removes all spaces and sets dashes instead, while having the string be all lower-case characters. It sounds easy to achieve, we are replace wizards after all; but we’ll see that some cases might not be so straightforward.

First thing that comes to mind is probably:

function spinalCase(str) {
  return str.replace(/ /g, '-').toLowerCase();

We first replace all spaces with dashes, and then get rid of capital letters. And you see, that works for strings such as:

spinalCase('Hello world!'); //-> hello-world!

spinalCase('I want to see the world BURN.'); //-> i-want-to-see-the-world-burn.

But how about these other case?

spinalCase('Hey_I_got_you_this_time'); //-> hey_I_got_you_this_time

Let’s get rid of those underscores too!