mirror of
https://github.com/avinal/The-VM-to-HACK-Translator.git
synced 2026-01-09 22:58:33 +05:30
trim command updated
This commit is contained in:
12
vutility.cpp
12
vutility.cpp
@@ -14,14 +14,12 @@ std::vector<std::string> vutility::split(std::string str, char delimit)
|
||||
|
||||
std::string vutility::trim(std::string str)
|
||||
{
|
||||
if (str.substr(0, 2) == "//")
|
||||
if (str.find('/') != std::string::npos) // comments
|
||||
{
|
||||
str.erase();
|
||||
}
|
||||
else
|
||||
{
|
||||
str.erase(0, str.find_first_not_of(" \r\t\v\n")); //prefixing
|
||||
str.erase(str.find_last_not_of(" \r\t\v\n") + 1); //surfixing}
|
||||
str.erase(str.find('/'));
|
||||
}
|
||||
str.erase(0, str.find_first_not_of(" \r\t\v\n")); //prefixing
|
||||
str.erase(str.find_last_not_of(" \r\t\v\n") + 1); //surfixing}
|
||||
|
||||
return str;
|
||||
}
|
||||
Reference in New Issue
Block a user