Escape character for empty string

2.4k Views Asked by At

I have problem with a long product name :

TONER PRO HP LASERJET 1000/­1005/­1005W/­1200/­1220/­3300/­3310/­3320/­3330/­3380 C7115A (15A)

I need to break this product name on end of line,but my require is, allow only break after "/"

So result shold look like this:

TONER PRO HP LASERJET 1000/­1005/­1005W/­1200/­
1220/­3300/­3310/­3320/­3330/­3380 C7115A (15A)

I tried to replace character "/" with /­ But it generates a hyphen in the end of line :(.

Does exist any escape character, what behave like empty string but allow me to break my string on specified place ?

Thank for any advice :)

1

There are 1 best solutions below

1
On

For a forced line break, use <br> (if the string appears in a context where tags are allowed).

For a permitted line break (i.e., allowing the browser insert line break if needed), use either the nonstandard but widely supported <wbr> tag or the Unicode character ZERO WIDTH SPACE, U+200B, which can be written as &#x200b;.

You would need to repeat that at each permissible break point, e.g.

TONER PRO HP LASERJET 1000/<wbr>­1005/­<wbr>1005W/<wbr>­1200/<wbr>­1220/<wbr>­3300/<wbr>­3310/­<wbr>3320/­<wbr>3330/­<wbr>3380 C7115A (15A)

There are many oddities in line breaking in browsers, but the above should cover cases like this.