Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session

Removal of Space within Address lines

Avatar

Level 1

I have fields for each of the address parts but no way to bring them together based no the length of the city name.  I end up with a big gap if the city name is short or not enough room if its long.  How do I bring the fields together to eliminate space on address lines?

Text Fields:

Name

Address1

City

State

Zip

Example (current way prints):

Johns Auto Body

1234 Main St.

Los Angeles,        CA 90045

Example (how I need it with space removed):

Johns Auto Body

1234 Main St.

Los Angeles, CA 90045

1 Reply

Avatar

Level 10

Hi,

therefor you can use a regular expression and the replace method.

In this example we look for all spaces that occur twice or more and replace them with a single space.

this.rawValue = this.rawValue.replace(/\s\s+/gm, " ");