Vanarajan Vanarajan - 1 year ago 213
jQuery Question

How to trim the string using node.js?

I am trying to trim the string. I google it for trim.

The tips i am getting.

  1. name.trim(); -- Not recognized trim() function

  2. npm install --save string

    var S = require('string');
    S('hello ').trim().s; -- this also same issue

Can you any one assist me what is the problem of the above method or anything i have missed it?

Answer Source

You don't need jquery for this...

var str = "       Hello World!        ";
var trimmedStr = str.trim();

This will output the following in the console:

"Hello World!"

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download