How to loop the string to get unique name

[{
        "Checklist_0": "1"
    }, {
        "Checklist_1": "0"
    }, {
        "Checklist_2": "1"
    }, {
        "Checklist_3": "0"
    }, {
        "Checklist_4": "0"
    }, {
        "Checklist_5": "1"
    }, {
        "Checklist_6": "0"
    }
]

This is what my out I need to replace all the Checklist_i values with one value

Any suggestions?

1 answer

  • answered 2018-11-08 07:16 fubo

    Regular Expressions is one way

    string result = new System.Text.RegularExpressions.Regex("Checklist_[\\d]").Replace(input, "foo");