Skip to content
Advertisement

Parse and reformat text with optionally occurring trailing characters

Due to horrible and inconsistent formatting by a certain website we are receiving data from, I need to parse the following string and print new strings after replacing/removing one or two substrings.

JavaScript

Desired result:

JavaScript

How can I parse a line with two ‘-‘ into the corresponding Owner: name format?

My current code:

JavaScript

Advertisement

Answer

This will definitely fail in the future, because of the inconsistent format the data is being delivered in, but hey, at least it works now.

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement