M
Mitch Tishmack
Hi everyone, long time lurker here. Even longer Ruby user.
I have a minor problem with a utf8 string.
In short I see this behavior:
"Stuhlu".sub(/u/,'=FC')
=3D> "St=FChlu"
"Stuhlu".reverse.sub(/u/,'=FC').reverse
=3D> "Stuhl\274\303"
"Stuhlu".reverse.sub(/u/,'=FC').split(//).reverse.join
=3D> "Stuhl=FC"
The general goal is to sub the final "u" in that word with an =20
umlauted version and not the first. I started irb with -Ku so that I =20
get utf8 support in all things ruby. But the behavior of reverse on =20
the substituted string is really baffling me.
Does anyone know the reason for the weirdness of reverse after the =20
sub? The last version was a hack to get things to just work. Am I =20
mising a Regexp option that would make the final match work? I don't =20
normally look for a final match to substitute on. And reverse seemed =20
the most logical choice for a solution.
Any help would be appreciated!
Thanks,
Mitch=
I have a minor problem with a utf8 string.
In short I see this behavior:
"Stuhlu".sub(/u/,'=FC')
=3D> "St=FChlu"
"Stuhlu".reverse.sub(/u/,'=FC').reverse
=3D> "Stuhl\274\303"
"Stuhlu".reverse.sub(/u/,'=FC').split(//).reverse.join
=3D> "Stuhl=FC"
The general goal is to sub the final "u" in that word with an =20
umlauted version and not the first. I started irb with -Ku so that I =20
get utf8 support in all things ruby. But the behavior of reverse on =20
the substituted string is really baffling me.
Does anyone know the reason for the weirdness of reverse after the =20
sub? The last version was a hack to get things to just work. Am I =20
mising a Regexp option that would make the final match work? I don't =20
normally look for a final match to substitute on. And reverse seemed =20
the most logical choice for a solution.
Any help would be appreciated!
Thanks,
Mitch=