From: Gavin Kistner Date: 2011-08-13T00:27:47+09:00 Subject: Re: Odd regexp behavior --Boundary_(ID_6zU3/wC6ZvY5pbY2Y/cdiA) Content-type: text/plain; charset=ISO-8859-1; format=flowed Content-transfer-encoding: quoted-printable On Aug 12, 2011, at 07:28 AM, Glen Holcomb wrote:=0A= [...]=0A> Now as to why I'm looking for the \s before and the \s or $ afte= r. It=0A> turns=A0out that some of the user agent strings are in a format = like "\"Custom=0A> Agent\"=3D\"Mozilla ...\""\n=0A=0ASo, after a little di= gging on Stackoverflow I decided to try an explicit=0Alookahead. For what = ever reason it works.=0A=0A/\s(".*?")(?=3D\s|$)/ matches where /\s(".*?")(= \s|$)/ won't.=0A=A0=0AIt sounds like you have a solution, but don't unders= tand it. I'd like to help you understand it, but I don't understand what y= ou're trying to match. The sample string you provide above does not match = your regex (and obviously so, as there is never whitespace before a quote)= =0A=0ACould you please provide a single string that you're matching again= st, and describe what you are trying to match?= --Boundary_(ID_6zU3/wC6ZvY5pbY2Y/cdiA) Content-type: multipart/related; boundary="Boundary_(ID_6hjNC/lPLtMMSbby3dBETQ)"; type="text/html" --Boundary_(ID_6hjNC/lPLtMMSbby3dBETQ) Content-type: text/html; CHARSET=US-ASCII Content-transfer-encoding: 7BIT
On Aug 12, 2011, at 07:28 AM, Glen Holcomb <damnbigman@gmail.com> wrote:
[...]
> Now as to why I'm looking for the \s before and the \s or $ after. It
> turns out that some of the user agent strings are in a format like "\"Custom
> Agent\"=\"Mozilla ...\""\n

So, after a little digging on Stackoverflow I decided to try an explicit
lookahead. For what ever reason it works.

/\s(".*?")(?=\s|$)/ matches where /\s(".*?")(\s|$)/ won't.
 
It sounds like you have a solution, but don't understand it. I'd like to help you understand it, but I don't understand what you're trying to match. The sample string you provide above does not match your regex (and obviously so, as there is never whitespace before a quote).

Could you please provide a single string that you're matching against, and describe what you are trying to match?
--Boundary_(ID_6hjNC/lPLtMMSbby3dBETQ)-- --Boundary_(ID_6zU3/wC6ZvY5pbY2Y/cdiA)--