Mar-23-2019, 05:32 PM
(This post was last modified: Mar-23-2019, 05:32 PM by Clunk_Head.)
(Mar-23-2019, 05:27 AM)DeaD_EyE Wrote: Try this regex:This makes a lot of sense to me. I read this as after the string '"GET ', return the first string of characters of size one or more until a space is hit. Is it possible to have this method return the second quotation mark?reg = r'"GET \S+'
(Mar-23-2019, 04:31 PM)ichabod801 Wrote: I would use a non-greedy regex:
re.findall('\"GET .+?\"', entry)Regexes by default will get as much as possible, returning the largest possible match (they're greedy). The ? makes things like + and * stop at the first possible match.
As usual, ichabod, you have great advise. Unlike DeaD_EyE's solution yours returns the second quotation mark. My follow up question. Is there a situation where your solution would return a different solution than DeaD_EyE's? Other than the second quotation mark, that is.
Thanks to you both.