Extracting specific data from a string of number and letters. Regexp?
Hi, I have managed to make Max retrieve SMS messages from my mobile phone using the serial object and this is what I get back -
+CMGL: 2873, "REC UNREAD", "+61439017138"
the text message OK
So my question is how can I extract the words "the text message" from all the other info?
I have been able to use the regexp object with these atributes -
regexp \'(.+)\'
this works but I have to put apostrophes ' before and after the text in the message when I send it, which I don't want to have to do.
I am wondering if I can do something similar but get the text between the " after the number and the OK.
Any ideas would be greatly appreciated!
Cheers Tobi.
Hi Tobi,
Try this:
regexp ".*\+\d*.\s*(.*) OK"
It looks for a '+' (\+) followed by a list of digits (\d*) followed by another character (.) and some whitespace (\s*) and then captures everything after that but before " OK".
That "followed by another character" part should really match a double quote, but I couldn't seem to get it to work. I tried putting in a \" but it doesn't work. Anyone know why?
Anyway, that regular expression seems to work. Here's a patch demonstrating:
Thanks you very much, works excellently!