added R tool regexes to make them more robust