I am receiving data in a string like this
IN-PATIENT AND DAYCARE TREATMENT (HOSPITALIZATION)FOR ONLY PARENTS ||||||||||ACCIDENTAL INJURIES=COVERED|||||MEDICAL EMERGENCIES=COVERED FROM OPD AND OPD REIMBURSEMENT BASIS
I want to show this in listview. And I need to break it by ||||| and split it by =
Mean in the list it will show like
IN-PATIENT AND DAYCARE TREATMENT (HOSPITALIZATION)FOR ONLY PARENTS
ACCIDENTAL INJURIES : COVERED
MEDICAL EMERGENCIES : COVERED FROM OPD AND OPD REIMBURSEMENT BASIS
The issue is how can I break it by |||? because sometimes the length of | is 5 sometimes 10 and so on. I just want whenever | is come it's just skip remaining | and just break it.
I am doing like this
List wordings = wording.split('||||');
print(wordings);
List splited;
wordings.forEach((element) {
splited = element.split('=');
var displayPolicy = {'name': splited[0], 'value': splited[1]};
displayData.add(displayPolicy);
});
It's working but the issue in this is its only break when |||| is four i want to skip this at any length
Edit
I am now doing like this
String wording = data['records'][0]['policies'][0]['policywording'];
List wordings = wording.split(RegExp(r"[|]+"));
print(wordings);
List splited;
wordings.forEach((element) {
splited = element.split('=');
var displayPolicy = {'name': splited[0], 'value': splited[1]};
displayData.add(displayPolicy);
});
print(displayData);
when I print wordings it's showing like this
[IN-PATIENT AND DAYCARE TREATMENT (HOSPITALIZATION), , ||ACCIDENTAL INJURIES=COVERED, |MEDICAL EMERGENCIES=COVERED FROM OPD]
It's not splitting and showing an error
