My goal is to be able to define different sets of sub-strings that can be removed without eliminating the other strings. Open to better ideas.
What I have now is:
@outbound_text = " XTEST this is hidden XTEST hey there, what's up! XTEST this is also hidden XTEST but then I just keep writing here "
I tried the following but realized it was deleting hey there, what's up
if ENV['ENVIRONMENT'] == 'test'
# this will allow the XTEST string to come through
else # for production and development, remove the XTEST
unless @outbound_text.gsub!(/XTEST(.*)XTEST/ , '').nil?
@outbound_text.strip!
end
logger.debug "remove XTEST: #{@outbound_text}"
end
Open to different strings bookending what I need to remove (but the number of hidden sub-strings will vary so they can only be a beginning and end).
I think open to -- although have a number of them which get parsed, so open to using Nokogiri
to remove the hidden tags. I would need to spend some time to try that, but wanted to know if there were a simple gsub before trying it.