samedi 25 avril 2015

how to use regular expressions in swift?


I am trying to write a JSON parser in swift. I am writing functions for parsing different parts of JSON code. I wrote a string parser which detects a string from the JSON data, by checking the start with \" and if I meet with another \" it is separated and returned as a String but when I met with this JSON text:

{"gd$etag": "W\/\"D0QCQX4zfCp7I2A9XRZQFkw.\""}

the function I wrote failed in the above case since in the value part it has to recognise the whole as String while mine is working to collect only

W\/

Since I gave the condition as starting and ending with \" when I searched online I understood it is something in relation to regular expressions. So help me out to solve this!


Aucun commentaire:

Enregistrer un commentaire