【字符串操作】截取字符串
来源:互联网 发布:mac电脑双系统切换 编辑:程序博客网 时间:2024/04/30 02:49
eg:截取一段字符串中的若干信息
#include <stdio.h>#include <iostream>#include <regex>using namespace std;void main(){string strsrc = "http://192.168.1.108:88/my/test/func?";int pos = strsrc.rfind("/");if (string::npos != pos){string strfunc = strsrc.substr(pos+1).data();strfunc = strfunc.erase(strfunc.length()-1, 1);<span style="white-space:pre"></span>//FUNC string strurl = strsrc.substr(0, pos);}int poshttp = strsrc.find("http://");int posport = strsrc.rfind(":");if (string::npos != poshttp && string::npos != posport && (posport - poshttp) > strlen("http://")){string strip = strsrc.substr(poshttp+7, posport-poshttp-7);//获取ipstring strport = strsrc.substr(posport+1).data();int posported = strport.find("/");if (string::npos != posported){strport = strport.substr(0, posported);//获得端口int port;sscanf(strport.data(), "%d", &port);//端口转化为int//scanf获取屏幕输出源int abc =0 ;abc++;}}return;}
筛选出其中的func /IP /PORT等等信息
0 0
- 【字符串操作】截取字符串
- python截取字符串操作
- shell字符串截取操作
- python字符串截取操作
- 字符串简单截取、替换操作
- 字符串截取和查询操作
- AWK操作字符串的截取
- String类--字符串截取操作
- Swift3.1字符串截取操作
- 字符串操作 - 截取字符串长度代码段
- 字符串操作之字符串的截取
- 字符串截取
- 字符串截取
- 字符串截取
- 截取字符串
- 截取字符串
- 截取字符串
- 字符串截取
- 数据结构概述
- 创建和遍历二叉树
- 使用本地JConsole监控远程JVM(最权威的总结)
- [Java]学习笔记,随笔【二】
- Lua面向对象编程系列-通过Table和Closure来实现类机制
- 【字符串操作】截取字符串
- 关于Collection的一点点
- Gson解析多层嵌套的数组出现的问题
- 站在技术人员的角度说两句找合伙人的事情
- The processing instruction target matching "[xX][mM][lL]" is not allowed.
- PHP模拟链表_学习链表的一些操作
- 用git下载linux源码
- PHP学习笔记(四):require、require_once和include、include_once的区别
- php base64_decode 解码方法