<?php
namespace App\Utils\BaseParser\TextParser\Types;

/**
 * Alphanumeric characters
 * @author Lucian Sirbu
 *
 */
class StringDelimitedByString extends \App\Utils\BaseParser\TextParser\BlockRegexpAbstract
{
	protected $extractRegexp = "/^(?P<rawData>.__LENGHTS__)(?=(__VALUE__))/";

	public function  __construct($options = [], $parent = null)
	{
		if ($options['val']) {
			$this->extractRegexp = str_replace("__VALUE__", implode("|", array_map(function($str) {
				return preg_quote($str, "/");
			}, $options['val'])), $this->extractRegexp);
		}
		elseif ($options['val_regex']) {
			$this->extractRegexp = str_replace("__VALUE__", implode("|", array_map(function($str) {
				return $str;
			}, $options['val_regex'])), $this->extractRegexp);
		}

		$this->extractRegexp = str_replace("__LENGHTS__", $this->regexp_convertLengthsToUngreedyRegexpMultiplier($options['len'], $options['req']), $this->extractRegexp);

		$this->options = $options;
		$this->parent = $parent;
	}
}
