how to change next data in database:
jsonData = [{"given_date": "2 1.05. 2002 year"}]
to
jsonData = [{"given_date": "21.05.2002"}]
UPDATE table
SET given_date = regexp_replace(given_date, '(\s|[a-zA-Z])', '','');
regexp_replace takes the value in given_date and be replaced by third parameter (empty string), according to the second regular parameter (match the spaces and alphabets). The fourth parameter is option like 'g(global)', 'i(ignore case)';
Postgresql regexp_replace reference
\DB::table('tablename')
->where(...)
->update([
'given_date' => \DB::raw("regexp_replace(given_date, '(\s|[a-zA-Z])', '','')")
]);
preg_replace('/\s|[a-zA-Z]/', '', '2 1.05. 2002 year');