1.7 KiB
Basic ASCII hyphen
foo-bar bar-foo
Unicode dash variants - all are in the Pd category
foo-bar # EN DASH (U+2013) foo-bar # EM DASH (U+2014) foo-bar # HYPHEN-MINUS (U+2010) foo-bar # FIGURE DASH (U+2012) foo--bar # Two EN DASHes side-by-side foo---------bar # Mix of all
Other punctuation that looks like a dash but is not Pd
foo·bar # BULLET (U+00B7) foo/ bar # SOLIDUS (U+002F) foo- bar # EM DASH followed by a non-breaking space (U+00A0)
Edge cases
foo- -bar # ASCII hyphen, space, en dash, space, bar -foo-bar- # Hyphens at the start and end foo--bar- # Mixed dashes with trailing en dash
Test words surrounded by dashes - word boundaries
-foo- foo- -bar --foo-- foo--bar foo--bar foo---bar
Dashes embedded in words (should NOT be replaced if you keep word-boundaries)
f-oo-b-ar # “f-oo” (hyphen inside a word) fo-ob-ar # “fo-ob” (en dash inside a word)
Dashes as punctuation in a sentence
"foo - bar" # En dash surrounded by spaces "foo-bar" # No spaces "foo-bar" # EM dash, no spaces "foo-bar" # FIGURE dash "foo-bar" # HYPHEN-MINUS
Mix of Unicode whitespace
foo - bar # U+202F NARROW NO-BREAK SPACE foo\u2005-bar # U+2005 MEDIUM MATHEMATICAL SPACE
Multiple dashes with other punctuation
foo--bar # Two ASCII hyphens foo--bar # EM DASH + EM DASH foo---bar # HYPHEN-MINUS + EM DASH + FIGURE DASH
Apostrophes
Here's a “quote” with a mix of apostrophes: 'Don't' “re-write” 'my' “code”, ʹand ʽtʾe-sʾtʽ! Also, 'like this', or a full-width ', or a low-9 'and a high-reversed 'example'. (End of line.)
"This line should stay intact"