I'm trying to search a text for a match and return it with snippet around it. For this, I want to find match with regex, then cut the string using match index +- snippet radius (text.mb_chars[start..finish]).
However, I cannot get ruby's (1.8) regex to return match index which would be multi-byte aware.
I understand that regex is one place in 1.8 which is supposed to be utf aware, but it doesn't seem to work despite /u switch:
"Résumé" =~ /s/u
=> 3
"Resume" =~ /s/u
=> 2
Result should be the same if regex was really working in multibyte (/u), but it's returning byte index.
How you get match index in characters, not bytes?
Or maybe some other way to get snippet around (each) match?