Moi,
I’m new to ruby and even to regular expression, so I fear these might be
super simple. 2 Questions
I have a string (actually a java inner class file name) like
name = “com.foo.Outer$Inner.class”
and want to replace $ with $ (for the shell)
name.sub!(/$/,“\$”)
doesn’t work while
name[$/] = “\$”
does.
And the other one is with a line (from a config file) like
line = "option.name = “value 1” “value 2” "
and I’d like an expression that
1 gets me the stuff after the = , and whatever I do the = is always part
of the result
2 an expession that I could use with split that gets an array [
“option.name”,“value 1” , “value 2”]
Moi,
I’m new to ruby and even to regular expression, so I fear these might be
super simple. 2 Questions
I have a string (actually a java inner class file name) like
name = “com.foo.Outer$Inner.class”
and want to replace $ with $ (for the shell)
name.gsub(/$/, ‘$’)
And the other one is with a line (from a config file) like
line = "option.name = “value 1” “value 2” "
and I’d like an expression that
1 gets me the stuff after the = , and whatever I do the = is always part
of the result
2 an expession that I could use with split that gets an array [
“option.name”,“value 1” , “value 2”]
value = /=.*$/.match(line)[0]
(see ri Regexp.match and ri MatchData)