Working with Strings in a database

I have a website I am taking over from a client, which I will fully rebuild at some point, but for now I need to work with what I have.

They have a SINGLE field in the database that is something like this.

```Vehicle```:```Audi A3 Sportback```Colour```:```Black```Comment```:```It's a pretty car, low miles: come see today.``` 

I asked the previous developer why he started and ended the field in 3 backticks and used 3 backticks to separate each record pair and then used 3 backticks and a colon and another 3 backticks as a separator between the key/value.

His answer was that the users were adding comments with slashes, commas, colons, etc and he needed something the user would more than likely never use to land up with an end result of

Vehicle: Audi A3 Sportback
Colour: Black
Comment: It's a pretty car, low miles: come see today.

Now I would like to split that strange string he has into 3 database fields

vehicle colour comment
Audi A3 Sportback Black It’s a pretty car, low miles: come see today.

I would like to do this using a database query, and then a multi update, where it takes the full odd string from the query and adds just the relevant part to the correct column in my table.
Normally I would just do this through Regex in a text editor and dump it all back to my database, however in this case I can’t and kind of need to do it like this.

I am hoping to use the formatters inside the update server action to extract the part i need for each field.

Community Page
Last updated: