Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
using re.search()
#4
.* is greedy, and will consume as much as it can. If there's multiple newlines after GPGGA, then only the last would match the regex, and all the intermediates would show in your results (as you're seeing).

So you can either...
1) replace the .* with a character group that matches everything except a newline:GPGGA,([^\r\n]+)\r\n, or
2) add a non-greedy modifier to it: GPGGA,(.*?)\r\n
Reply


Messages In This Thread
using re.search() - by ebolisa - May-10-2021, 06:48 PM
RE: using re.search() - by bowlofred - May-10-2021, 07:30 PM
RE: using re.search() - by ebolisa - May-10-2021, 08:12 PM
RE: using re.search() - by bowlofred - May-10-2021, 09:43 PM
RE: using re.search() - by nilamo - May-10-2021, 08:37 PM
RE: using re.search() - by Gribouillis - May-11-2021, 06:06 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020