I have an input: 'BOOM', 'GRE,M', 'H SE', 1,2
Now, I want to split the string on the conditions:
- If it a word in the string is surrounded by a single quote, remove the single quote e.g
'BOOM'==> BOOM,'GRE,M' ==> GRE,M,'H SE'==> H SE(the space should be kept). So, as the example shows, if the word has a space as in the "'H SE'" example, only the single quote should be removed and the space preserved. - if it is a word with no single quote, then do nothing e.g
1 ==>1,2==>2
I have a regex '(.*)', but this only takes care of words, within the single quotes. So, with the regex, I could easily get the following: BOOM, GRE,M, H SE BUT NOT the 1, and 2. What regex will do this?
Aucun commentaire:
Enregistrer un commentaire