I have this regular expression and I want to replace the "lb" part with the parameter that's being passed in with what ever weight they want to use so what I have is this
protected function validateCheckWeight($attribute, $value, $parameters)
{
// this always outputs correctly either true or false
return preg_match('/^(?!0\d|0lb$)\d+(?:\.\d+)?lb$/', $value);
}
and what I want is this but it doesn't work when doing validation
protected function validateCheckWeight($attribute, $value, $parameters)
{
return return preg_match('@/^(?!0\d|0' . $parameters[0] .'$)\d+(?:\.\d+)?' . $parameters[0] . '$/@', $value);
}
protected function validateCheckWeight($attribute, $value, $parameters)
{
dd('@/^(?!0\d|0' . $parameters[0] .'$)\d+(?:\.\d+)?' . $parameters[0] . '$/@');
// output "@/^(?!0\d|0kg$)\d+(?:\.\d+)?kg$/@"
return preg_match('@/^(?!0\d|0' . $parameters[0] .'$)\d+(?:\.\d+)?' . $parameters[0] . '$/@', $value);
// this always outputs false
}
$attribute,$valueand$parameters, and what return value are you expecting?$attributeargument is never used.$value?