Forum: Rails France Regex Problem

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
0273c9b033bc47a97ab598c0cb44beca?d=identicon&s=25 Cyril J. (cyril_j)
on 2011-09-09 16:41
I have a regex problem. I am trying to match this string : >1_4_138_F3

Here is my code:

if f3_entry =~ /(\^>*\_*\_*\_F3)/
  f3_out.puts f3_entry

Not exactly sure if I am in the right direction or not, but I want to
use the underscore as the matching point, while anything can be between
the underscores. Can anyone point me in the right direction?

- C
464abd6ab9c48c6add2050b1ee1f944d?d=identicon&s=25 Azuma -. (azuma-01)
on 2011-11-03 17:35
your regex should be more like this:

so $1 (variable where the frist match is stored), when maching with
those string
  ">1_4_138_F3: rest of the line"
  ">55_1087_98_F3 rest of the line"
will respectively return

if the string most only be like ">1_4_138_F3" add the symbol '$' at the
end of the regex (/^(>\d+_\d+_\d+_F3)$/)

hope this helps
This topic is locked and can not be replied to.