D
David Alm
I'm new to both Ruby and RegExp.
I'm wanting to do a string sub in lines of a file but have the match
criteria for gsub be case-independent. The only think I could think of was
to upcase the whole thing:
content = File.readlines( x ).collect! { |line|
if ( line =~ /someLineCriteria.*$/ )
line.upcase!.gsub(/SOME_GSUB_CRITERIA/, $string_to_sub )
else
line
end
}
But I would prefer not to have to upcase it all, and have the RE match
"SomE_Gsub_CRITeria" or any similar combination of upper/lower case.
Thanks in advance.
I'm wanting to do a string sub in lines of a file but have the match
criteria for gsub be case-independent. The only think I could think of was
to upcase the whole thing:
content = File.readlines( x ).collect! { |line|
if ( line =~ /someLineCriteria.*$/ )
line.upcase!.gsub(/SOME_GSUB_CRITERIA/, $string_to_sub )
else
line
end
}
But I would prefer not to have to upcase it all, and have the RE match
"SomE_Gsub_CRITeria" or any similar combination of upper/lower case.
Thanks in advance.