Symantec Interview Question
Senior Software Development EngineersTeam: DS
Country: India
Interview Type: Phone Interview
#include <boost/regex.hpp>
#include <string>
#include <iostream>
int main()
{
std::string s ="L\"\\?\\UNC\\10.1.3.23\\TOKEN$\\0x46456\\C\\FileDrive\\Testcase.doc";
boost::regex expr{"(\\\\)0x(\\d)+"};
std::string fmt{""};
std::cout << boost::regex_replace(s, expr, fmt) << '\n';
}
#include <iostream>
#include <string>
using namespace std;
int main()
{
cout << "Hello world!" << endl;
string ss ="L\"\\?\\UNC\\10.1.3.23\\TOKEN$\\0x432567\\C\\FileDrive\\Testcase.doc";
std::cout << ss<< "\n";
std::string::size_type n = ss.find("TOKEN$");
std::string::size_type first = ss.find("\\",n);
std::string::size_type last = ss.find("\\",first+1);
if (n == std::string::npos) {
std::cout << "not found\n";
} else {
ss.replace(first,(last-first),"");
std::cout << "found: " << ss << '\n';
}
return 0;
}
int main()
{
string ss ="L\"\\?\\UNC\\10.1.3.23\\TOKEN$\\0x432567\\C\\FileDrive\\Testcase.doc";
std::cout << ss<< "\n";
std::string::size_type n = ss.find("TOKEN$");
if (n == std::string::npos) {
std::cout << "not found\n";
} else {
std::string::size_type first = ss.find("\\",n);
std::string::size_type last = ss.find("\\",first+1);
ss.replace(first,(last-first),"");
std::cout << "found: " << ss << '\n';
}
return 0;
}
{{
- Rajarathinam Antony December 09, 2015#include <cstdio>
#include <string>
#include <iostream>
#include <vector>
#include <regex>
using namespace std;
int main ()
{
string result;
string string_to_split ="L\"\\?\\UNC\\10.1.3.23\TOKEN$\\C\\FileDrive\\Testcase.doc";
std::regex rgx("TOKEN\\$");
std::sregex_token_iterator iter(string_to_split.begin(),
string_to_split.end(),
rgx,
-1);
std::sregex_token_iterator end;
for ( ; iter != end; ++iter)
{
result += *iter;
}
std::cout << result << '\n';
return 0;
}
}}