Method: Parsec::Parsec.sanitize

Defined in:
lib/parsec.rb

.sanitize(equation, new_line = false) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/parsec.rb', line 47

def self.sanitize(equation, new_line = false)
  equation = equation.gsub(/[\n\t\r]/, ' ')

  # The following regex remove all spaces that are not between quot marks
  # https://tinyurl.com/ybc7bng3
  if new_line == true
    equation.gsub!(/( |("([^"\\]|\\.)*")|('([^'\\]|\\.)*'))/, '\\2')
  end

  equation
end