Hey, I am using a reg expression to remove parentheses and the content between them from a ruby string. The problem is that this sometimes leaves a space before commas. I am not sure how to go about removing this space. I've been playing around with the following but it has not been working:
@char_count = 0
sentance.each_char{|char|
if char == ","
if sentance[@char_count-1] == 32
sentance[@char_count-1] = ""
end
end
@char_count += 1
}
Any help is appreciated!
Edit: sentance.gsub!(/ ,/, ',') is working well, but now I am realizing that there are some places where there are multiple spaces before a comma. I need to account for this scenerio as well.