Regular Expressions 101

Community Patterns

Split long paragraph to segments within specified length

0

Regular Expression
PCRE (PHP <7.3)

/
(?:(?!.{1,30}(?:\.\s|\.$|\?\s|\?$|;\s|;$|||))(?:.{30}))|(?:.{1,30}(?:\.\s|\.$|\?\s|\?$|;\s|;$|||))
/
gs

Description

Try to split at the longest point whereas sentences ended.

Submitted by anonymous - 5 years ago