开发者

Parsing char array in C++

开发者 https://www.devze.com 2023-03-28 08:00 出处:网络
I\'m coding a httpser开发者_开发技巧ver and I\'m stuck at parsing GET requests. How would I parse a char buffer with something like

I'm coding a httpser开发者_开发技巧ver and I'm stuck at parsing GET requests. How would I parse a char buffer with something like

GET /images/logo.png HTTP/1.1

So that I only get the path and file extension but ignore the other parts?


You don't say specifically say what sort of storage this string is in - simple char* or some string class.

So, in general, you could either do it the rather simple and dirty way, by splitting the string on the space character, and taking the second or middle section. Or, a better approach would be to get familiar with Regular Expressions. C++ has several regex libraries - Boost is well regarded.

0

精彩评论

暂无评论...
验证码 换一张
取 消