From: Glen Holcomb Date: 2011-08-13T03:28:02+09:00 Subject: Re: Odd regexp behavior --bcaec50161e9c7bf9b04aa53123c Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 2011/8/12 Bartosz Dziewo=C5=84ski > Because, when the (\s|$) at the end matches \s (a space), this space > is no longer included in subsequent matches - as if that part of > string "disappeared" - and thus the \s at the beginning can't match > it. You should use a regex tester for complex regexes (by complex, I > mean almost all), for example http://regexpal.com/. (Try inputting > your data and both of your regexes there.) > > I think there's a similar tool that explicitly uses Ruby's flavor of > regexp (regexpal uses browser-side JavaScript), but I can't remember > the URL and AFAIR it sucked. > > -- Matma Rex > > Actually I don't think that was the case. Here is my gsub block encapexs.each do |encapex| line.gsub!(encapex) do |match| x.next! stash[x] =3D $1 separator + x + separator end end So, it should have been and appeared to be putting the space back into the line. I really need to modify my regex and grab the preceding space in it'= s own group so I can clean the last line up some. --=20 "Hey brother Christian with your high and mighty errand, Your actions speak so loud, I can=E2=80=99t hear a word you=E2=80=99re saying." -Greg Graffin (Bad Religion) --bcaec50161e9c7bf9b04aa53123c--