I have the following code in my Laravel 5 app:
public function store(Request $request){
$this->validate($request, ['filename' => 'regex:[a-zA-Z0-9_\-]']);
}
My intentions are to permit filenames with only alphanumeric characters, dashes and underscores within them. However, my regex is not working, it fails even on a single letter. What am I doing wrong?
'regex:/^[a-zA-Z0-9_-]*$/'
or just'regex:/^[\w-]*$/'
. – Spitz/.../
) and anchors (^...$
). – Malik