I am currently dealing with the outputs of a system within my organization that I do not have control over.
Here is a sample string:
let structure = 'LAWYER=|FIRM=|SUIT_DESCRIPTION=|DEF_COMMENT=|PLF_COMMENT=|';
This string continues on, but follows this pattern.
Now, there is another string similar to the first one, but with actual data assigned to it, like in this example:
let currentData = 'FIRM=Smith and Wesson LLP|SUIT_DESCRIPTION=It\'s a royal mess|PLF_COMMENT=some freeform text|LAWYER=Bob Smith';
It should be noted that not all elements from structure may necessarily be found in currentData, and the order might vary (if the sequence is crucial, I can ensure they match).
My goal is to extract every element present in currentData and populate the corresponding item in structure, if it exists. Alternatively, I can add any non-matching elements from structure into currentData, ideally maintaining the same order as in structure.
Based on the provided data, the desired outcome would be:
result = 'LAWYER=Bob Smith|FIRM=Smith and Wesson LLP|SUIT_DESCRIPTION=It\'s a royal mess|DEF_COMMENT=|PLF_COMMENT=some freeform text|';
I am not very experienced with JavaScript :(
I attempted various methods in JSFiddle using split() and match(), but it only resulted in confusion for me.