{"action":"created","issue":{"url":"https://api.github.com/repos/armadsen/ORSSerialPort/issues/90","labels_url":"https://api.github.com/repos/armadsen/ORSSerialPort/issues/90/labels{/name}","comments_url":"https://api.github.com/repos/armadsen/ORSSerialPort/issues/90/comments","events_url":"https://api.github.com/repos/armadsen/ORSSerialPort/issues/90/events","html_url":"https://github.com/armadsen/ORSSerialPort/issues/90","id":111607983,"number":90,"title":"PacketDescriptor using Regex","user":{"login":"pjmnoble","id":8706817,"avatar_url":"https://avatars.githubusercontent.com/u/8706817?v=3","gravatar_id":"","url":"https://api.github.com/users/pjmnoble","html_url":"https://github.com/pjmnoble","followers_url":"https://api.github.com/users/pjmnoble/followers","following_url":"https://api.github.com/users/pjmnoble/following{/other_user}","gists_url":"https://api.github.com/users/pjmnoble/gists{/gist_id}","starred_url":"https://api.github.com/users/pjmnoble/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pjmnoble/subscriptions","organizations_url":"https://api.github.com/users/pjmnoble/orgs","repos_url":"https://api.github.com/users/pjmnoble/repos","events_url":"https://api.github.com/users/pjmnoble/events{/privacy}","received_events_url":"https://api.github.com/users/pjmnoble/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-15T12:40:11Z","updated_at":"2015-10-15T16:52:35Z","closed_at":null,"body":"Hi, \r\n\r\nI have the NSRegular expression below used in a packetDescriptor to validate  a coordinates string such as \"167628,79009\\r\" delivered via a serial port using ORSSerialPort requestResponse API. The expression, however leads to the delegate serialPort: didReceiveResponse: data containing \"8,79009\". \r\n\r\nIf I replace the regex with \"(\\\\d{5}),(\\\\d+)\\r\" it works and I get \"167628,79009\" (so ORSSerialPort is building the correct string) but this will only be useful when the coordinates delivered are a 5 digit number. If I use d{1,5} I get the same result as when using the line-start anchor.\r\n\r\nThe regex is ignoring the anchors. Any Suggestions ?\r\n\r\nCode for the regex and packetDescriptor used\r\n\r\n    coordinatePacketRegex = [[NSRegularExpression alloc] initWithPattern:@\"^(\\\\d+),(\\\\d+)\\r\"\r\n                                                                   options:NSRegularExpressionAnchorsMatchLines\r\n                                                                       error:&regexError];\r\n\r\n    coordinateDescriptor = [[ORSSerialPacketDescriptor alloc] initWithRegularExpression: coordinatePacketRegex\r\n                                                                    maximumPacketLength:12\r\n                                                                      userInfo:Null;"},"comment":{"url":"https://api.github.com/repos/armadsen/ORSSerialPort/issues/comments/148453774","html_url":"https://github.com/armadsen/ORSSerialPort/issues/90#issuecomment-148453774","issue_url":"https://api.github.com/repos/armadsen/ORSSerialPort/issues/90","id":148453774,"user":{"login":"armadsen","id":1057175,"avatar_url":"https://avatars.githubusercontent.com/u/1057175?v=3","gravatar_id":"","url":"https://api.github.com/users/armadsen","html_url":"https://github.com/armadsen","followers_url":"https://api.github.com/users/armadsen/followers","following_url":"https://api.github.com/users/armadsen/following{/other_user}","gists_url":"https://api.github.com/users/armadsen/gists{/gist_id}","starred_url":"https://api.github.com/users/armadsen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/armadsen/subscriptions","organizations_url":"https://api.github.com/users/armadsen/orgs","repos_url":"https://api.github.com/users/armadsen/repos","events_url":"https://api.github.com/users/armadsen/events{/privacy}","received_events_url":"https://api.github.com/users/armadsen/received_events","type":"User","site_admin":false},"created_at":"2015-10-15T16:52:35Z","updated_at":"2015-10-15T16:52:35Z","body":"Hi pjmnoble,\r\n\r\nThanks for opening this issue. Fundamentally, this is the same issue as #89. Packets are parsed one byte at a time looking backwards from the most recently received byte. The smallest chunk of data that matches the regex is considered to be a valid packet. This is to prevent bad data sitting at the beginning of the buffer from being interpreted as being part of the packet.\r\n\r\nI'm still considering the best way to solve #89. I'm glad you found this, because it's a case I hadn't thought of. It seems like it might make sense for regex-based packet descriptors to be matched against the entire buffer. If not always, at least when the regex contains a line-start anchor.\r\n\r\nIn your case, is it true that the coordinates are always 5-digit numbers (your example shows the first value as a 6-digit number...)? If so, I think the solution you found is a fine workaround. If not, it helps me prioritize a fix for this :)"}}