From: Chris Hulan Date: 2013-05-24T03:36:44+09:00 Subject: Re: Regular expression to find a break in a pattern --f46d0447878dc53bd704dd66f6c9 Content-Type: text/plain; charset=ISO-8859-1 Here's a regex that captures all the cases where To matches From: http://www.rubular.com/r/I8g4QOUNGP Can't find an easy switch to find the mismatch as you need, but maybe it'll provide a starting point. Plus Rubular is a great resource for exploring regex cheers On Thu, May 23, 2013 at 1:33 PM, Derrick B. wrote: > regex capturing with assignment. Capture your string or number in the > From field using parenthesis to capture and assign: /(\d+)/ > ...then compare the assigned value, which is $1, with the next string > > Sorry to do this to your all, but this is a quick Perl example I just > whipped up, but is easy to convert to Ruby: > > perl -le '$x = "12345"; $y = "123465"; > if ( $x =~ /(\d+)/ ) { > if ( $y == $1 ) { > print "yep" > } > else { > print "nope!" > } > } > ' > > -- > Posted via http://www.ruby-forum.com/. > > --f46d0447878dc53bd704dd66f6c9 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Here's a regex that captures all the cases where To ma= tches From:
http://www.= rubular.com/r/I8g4QOUNGP

Can't find an= easy switch to find the mismatch as you need, but maybe it'll provide= =A0
a starting point.
Plus Rubular is a great resource for explo= ring regex

cheers


On Thu, May 23, 2013 at 1:33 PM, D= errick B. <lists@ruby-forum.com> wrote:
regex capturing with assignment. =A0Capture = your string or number in the
From field using parenthesis to capture and assign: =A0/(\d+)/
...then compare the assigned value, which is $1, with the next string

Sorry to do this to your all, but this is a quick Perl example I just
whipped up, but is easy to convert to Ruby:

perl -le '$x =3D "12345"; $y =3D "123465";
=A0if ( $x =3D~ /(\d+)/ ) {
=A0 =A0 =A0if ( $y =3D=3D $1 ) {
=A0 =A0 =A0 =A0 =A0print "yep"
=A0 =A0 =A0}
=A0 =A0 =A0else {
=A0 =A0 =A0 =A0 =A0print "nope!"
=A0 =A0 =A0}
=A0}
'

--
Posted via http://= www.ruby-forum.com/.


--f46d0447878dc53bd704dd66f6c9--