Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list

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