Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session

How can i condense in JavaScript?

Avatar

Level 8

Hello

In some other scripts, we have the below syntax to ERASE all the left spaces or zeros & condenses finally, makes it a meaningful string with a good intendation,

SHIFT my_variable LEFT DELETING LEADING spaces/zeros,

do we have a EQUIVALENT code in JavaScript?

Thank you

2 Replies

Avatar

Level 2

Hi,

To remove leading space;

string.replace(/^\s+/, "");

To remove leading zero;

string.replace("/^0+/","");

It's same as general javascript.

Cheers!

Avatar

Level 10

Hi,

I designed a macro for Designer ES2 (9.x) and ADEP Designer (10.x).

It looks for JavaScripts in a form template and beautifies them, means the script are formatted in that way a JavaScript should look like.

This also removes all unneccassary leading and trailing spaces.

http://thelivecycle.blogspot.com/2011/08/javascript-beautifier.html