Unable to manipulate string inside section

I have some data which is a string, I’m passing it into a section with the following method:

{%- liquid
assign myData = 'data],[data],[data'

capture header
section 'header
endcapture

assign header = header | replace: '%%DATA%%', myData
-%}

Then within ‘sections/header.liquid’ I have the following:

{% capture replaced_data %}
%%DATA%%
{% endcapture %}

{%- liquid
    assign data = replaced_data | split: '],['

    echo data[0]
-%}

Now based off that, you’d expect the first data to be printed out, but infact the following is printed out:

data],[data],[data

For some reason I’m no longer able to do any manipulation with this data once its in the ‘sections/header.liquid’ file. I’ve even tried doing a replace on the ],[ but it just doesn’t take effect.

Anybody experienced similar?

Continuing to try and troubleshoot this, I tried doing the following:

assign data = replaced_data | append: '],[' | remove: '],['

This adds ‘],[’ on the end and succesfully removes it, but it does not remove the ‘],[’ in the rest of the string of ‘replaced_data’. Its almost like the ‘replaced_data’ string is read only