Am 06.10.2012 01:11, schrieb Brad Askins:
> Hi, new to the forum, not new to Ruby but very new to Regular Expression
> and they are killing me...
>
> I have strings that look like this:
> "--- this is a string ---" = "--- this is a string ---";
> "  this is a string  " = "  this is a string  ";
> "###this is a string" = "###this is a string";
>
> I need to just get both string on each side to the equal sign, not
> including the equal sign. I need to get all spaces or characters inside
> the quotes but not including the quotes and not the semi-colon. I need
> to compare the two strings. So...
>
> this is a string this is a string
>
> I tried using string.scan/regex/ which I like because it returns an
> array. Again Fail.
>
> I've tried all kinds of RegEx...I simply don't know what I'm doing and I
> very frustrated. I have been using http://rubular.com/ to experiment but
> I'm really not having success...
>
> My most successful attempt, [^"=;] gets pretty much what I need but I
> can't not select the space around the =.

1.9.3-p194 :001 > text = '"--- this is a string ---" = "--- this is a 
string ---";'
  => "\"--- this is a string ---\" = \"--- this is a string ---\";"
1.9.3-p194 :002 > text.scan(/"(.*?)" = "(.*?)"/).flatten
  => ["--- this is a string ---", "--- this is a string ---"]


-- 
<https://github.com/stomar/>