Finding out specific string in C/C++ -
Finding out specific string in C/C++ -
i have info in next form:
http://website.org/resource/id_xa5x8p_1sz_1s8rhrc http://website.org/resource/abc http://website.org/resource/id_xa5x8p_1sz_1s8rfcc http://website.org/resource/def http://website.org/resource/ghi http://website.org/resource/id_xa5x8p_1sz_1s8ryurc http://website.org/resource/id_xa5x8p_1sz_1s8rhrcwjf http://anyother/anthingelse/id_xa5x8p_1sz_1s8rhrc file://anyotherinfo/anthingelse1/id_xa5x8p_1sz_1s8rhrc file://anyotherinfo/anthingelse1/def/id_xa5x8p_1sz_1s8rhrc file://id_anyotherinfo/anthingelse1/def/id_xa5x8p_1sz_1s8rhrc file://anyotherinfo/id_anthingelse1/def/id_xa5x8p_1sz_1s8rhrc file://anyotherinfo/id_anthingelse1/def/ghi
my expected output is:
http://website.org/resource/id_xa5x8p_1sz_1s8rhrc http://website.org/resource/id_xa5x8p_1sz_1s8rfcc http://website.org/resource/id_xa5x8p_1sz_1s8ryurc http://website.org/resource/id_xa5x8p_1sz_1s8rhrcwjf http://anyother/anthingelse/id_xa5x8p_1sz_1s8rhrc file://anyotherinfo/anthingelse1/id_xa5x8p_1sz_1s8rhrc file://anyotherinfo/anthingelse1/def/id_xa5x8p_1sz_1s8rhrc file://id_anyotherinfo/anthingelse1/def/id_xa5x8p_1sz_1s8rhrc file://anyotherinfo/id_anthingelse1/def/id_xa5x8p_1sz_1s8rhrc
now want find out url's have characters "id_" after lastly slash. 1 of ways know , have implemented parse string character character start , store string array till space. pick lastly array , find whether has id_ in beginning.
but problem array size in c++ assigned apriori, lending approach infeasible when there many slashes. there other way of finding out.
std::string::find_last_of
if know you're looking "/id_" utilize find_last_of lastly occurrence.
you might want find lastly instance of "/" confirm id_ found after lastly "/".
c++
Comments
Post a Comment