Fill available spaces between labels with dots or hyphens

后端 未结 6 620
栀梦
栀梦 2020-11-30 04:46

I have a page with labels which are contained in a div, the labels has a variable with and i want to fill spaces between both with characters, dots or \'-\'.

For ex

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-30 05:19

    1. Find the first instance of three spaces. I am assuming that this is the minimum number needed to constitute a "break"

    2. Find the first non-space character after that.

    3. Replace all the spaces between the index in #1 (+1) and the index in #2 (-1). That would give you the results above.

    Check other answers for more clean ways to do it with CSS. That would be the cleanest way to display the text. Dashes look ghetto. :)

提交回复
热议问题