Skip to content

Commit

Permalink
Updated terminatorRegex in the parser
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomek committed Jan 5, 2025
1 parent 0832384 commit 55eb38a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/EDI/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -522,10 +522,10 @@ private function unwrap(string &$string): array
$this->errors[] = 'This file contains some segments without terminators';
}

$terminatorRegex = '/(([^'.$this->symbRel.']'.$this->symbRel.'{2})+|[^'.$this->symbRel.'])'.$this->symbEnd.'|[\r\n]+/';
$terminatorRegex = '/((?<!'.$this->symbRel.')(?:'.$this->symbRel.$this->symbRel.')*)'.$this->symbEnd.'|[\r\n]+/';

if ($this->strict) {
$terminatorRegex = '/(([^'.$this->symbRel.']'.$this->symbRel.'{2})+|[^'.$this->symbRel.'])'.$this->symbEnd.'/';
$terminatorRegex = '/((?<!'.$this->symbRel.')(?:'.$this->symbRel.$this->symbRel.')*)'.$this->symbEnd.'/';
}

$string = (string) \preg_replace(
Expand Down

0 comments on commit 55eb38a

Please sign in to comment.