Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
PCRE (PHP <7.3)

/
.{1,80}(\s|$)|\S+?(\s|$)
/
g

Description

Used in JavaScript, can create a string of hard word-wrap text. Expression used 80 as the word-wrap point, but it can be changed to suit your purpose. RegEx provided by @DanThomas. TAGS: @WordWrap @Word-Wrap

Submitted by anonymous - 8 years ago