Copied!

Simple output wrapper for "tagged outputs" instead of wordwrap(). This solution is based on a StackOverflow answer: https://stackoverflow.com/a/20434776/1476819 from user557597 (alias SLN).

(?: # -- Words/Characters ( # (1 start) (?> # Atomic Group - Match words with valid breaks .{1,16} # 1-N characters # Followed by one of 4 prioritized, non-linebreak whitespace (?: # break types: (?<= [^\S\r\n] ) # 1. - Behind a non-linebreak whitespace [^\S\r\n]? # ( optionally accept an extra non-linebreak whitespace ) | (?= \r? \n ) # 2. - Ahead a linebreak | $ # 3. - EOS | [^\S\r\n] # 4. - Accept an extra non-linebreak whitespace ) ) # End atomic group | .{1,16} # No valid word breaks, just break on the N'th character ) # (1 end) (?: \r? \n )? # Optional linebreak after Words/Characters | # -- Or, Linebreak (?: \r? \n | $ ) # Stand alone linebreak or at EOS )

CloneableFinalInstantiable
Methods
public __construct(bool $allowCutUrls = false)
public wrap(string $text, int $width, string $break = ' ') : string
Constants
private Symfony\Component\Console\Helper\OutputWrapper::TAG_CLOSE_REGEX_SEGMENT = '[a-z][^<>]*+'
private Symfony\Component\Console\Helper\OutputWrapper::TAG_OPEN_REGEX_SEGMENT = '[a-z](?:[^\\<>]*+ | \\.)*'
private Symfony\Component\Console\Helper\OutputWrapper::URL_PATTERN = 'https?://\S+'
Properties
private bool $allowCutUrls
© 2024 Bruce Wells
Search Namespaces \ Classes
Configuration