Suppose I have a long string like 4600airportburlingame150anzablvd.burlingamecalifornia94010
. My code is breaking on this string. This is unusual, 99% of entries will not have a period. The CSS in the browser wraps if there are spaces in the string and there isn't any here.
- How do I detect the period
(".")
and insert a space directly after it? Remember 99% of strings will not have a period in them. The code has to detect if it has a period and if so, do the insertion, otherwise not. - If I determine a maximum string length, how do I insert a space at some length?
Best Answer
①
To insert a space after every dot:
To insert a space after every dot except for the dots that already have a space or dots at the end of the string:
②
To insert a space after every n characters: