code: private function validateUrl(Request $request , ConfigContainer $config , $position){
  		$url=$request->getUrl();
  		$default=$config->getValue('default');
  		if(preg_match('/^'.$config->getValue('pattern').'$/',$url,$matches) && isset($matches[1])){
  			return $matches[1];			
  		}
  		else if($default!==false){
  			return $config->getValue('default');
  		}
  		else{
  			throw new RequiredArgumentException($position,$config->getValue('name'));
  		}
  	}
docs: Validate url.
  
  @param Request $request
  @param ConfigContainer $config argument
  @param int $position
  @return string
  @throws RequiredArgumentException