You would get a better answer if you presented an example using dataex (Stata 15.1 or SSC). Here's my guess at what you want:
and the results:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str142 icd "[ICD-401.9] Ipertensione essenziale non specificata,[ICD-272.2] Iperlipidemia mista,[ICD-278.02] Sovrappeso,[ICD-427.31] Fibrillazione atriale" end moss icd, match("(\[[^[]+)") regex list _match*
Code:
. list _match* +-------------------------------------------------------------+ 1. | _match1 | | [ICD-401.9] Ipertensione essenziale non specificata, | |-------------------------------------------------------------| | _match2 | _match3 | | [ICD-272.2] Iperlipidemia mista, | [ICD-278.02] Sovrappeso, | |-------------------------------------------------------------| | _match4 | | [ICD-427.31] Fibrillazione atriale | +-------------------------------------------------------------+
Comment