This document contains the content of /resources/docs/text/regex_ellipsis_truncation.txt. Download the file by setting the ?act=download parameter, or access the raw file at either srcs.cc or src.cerium.cc.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Truncates text at the beginning or end of a string, replacing truncated text
# with an ellipsis (…) (U+2026).
# Uses the format:
# /pattern/flags, 'substitution'
# First 10 characters.
/(.{10}).+/, '$1…'
# First 10 characters, must truncate at least 3 characters.
/(.{10}).{3,}/, '$1…'
# Last 10 characters.
/.+(.{10})/, '…$1'
# Last 10 characters, must truncate at least 3 characters.
/.{3,}(.{10})/, '…$1'
# First and last 5 characters.
/(.{5}).+(.{5})/, '$1…$2'
# First and last 5 characters, must truncate at least 3 characters.
/(.{5}).{3,}(.{5})/, '$1…$2'
More resources