Reputation: 329
how to change next data in database:
jsonData = [{"given_date": "2 1.05. 2002 year"}]
to
jsonData = [{"given_date": "21.05.2002"}]
Upvotes: 0
Views: 347
Reputation: 13394
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])', '','')")
]);
Upvotes: 1