当前位置:网站首页>Get the position of the nth occurrence of the string
Get the position of the nth occurrence of the string
2022-07-06 12:22:00 【Silence, your name】
/**
* Delete the specified column
*
* @param str | Parameter name | Parameter description | Whether must | data type | schema |
* @param column 6
* @return | Parameter name | Parameter description | Whether must | data type |
* @throws Exception Exception
*/
private static String removeColumn(String str, int column) throws Exception {
int startIndex = getIndexOf(str, column);
int endIndex = getIndexOf(str, column + 1);
return str.substring(0, startIndex) + str.substring(endIndex);
}
/**
* Get the string number N The location of the second occurrence
*
* @param line | Parameter name | Parameter description | Whether must | data type | schema |
* @param count How many times
* @return index Index subscript
*/
private static int getIndexOf(String line, int count) {
int index = 0;
int findCount = 0;
while ((index = line.indexOf("|", index)) != -1) {
if (++findCount == count) {
return index;
}
index++;
}
throw new RuntimeException(line + "-------" + count);
}
边栏推荐
- Arduino JSON data information parsing
- ES6 grammar summary -- Part I (basic)
- RuntimeError: cuDNN error: CUDNN_STATUS_NOT_INITIALIZED
- 基于Redis的分布式ID生成器
- gcc 编译选项
- [golang] leetcode intermediate - fill in the next right node pointer of each node & the k-smallest element in the binary search tree
- Common properties of location
- map文件粗略分析
- I2C bus timing explanation
- Several declarations about pointers [C language]
猜你喜欢
Redis cache update strategy, cache penetration, avalanche, breakdown problems
Detailed explanation of Union [C language]
Basic operations of databases and tables ----- view data tables
Kconfig Kbuild
Cannot change version of project facet Dynamic Web Module to 2.3.
Postman 中级使用教程【环境变量、测试脚本、断言、接口文档等】
ESP8266连接onenet(旧版MQTT方式)
Time slice polling scheduling of RT thread threads
Fashion Gen: the general fashion dataset and challenge paper interpretation & dataset introduction
[esp32 learning-2] esp32 address mapping
随机推荐
(四)R语言的数据可视化——矩阵图、柱状图、饼图、散点图与线性回归、带状图
. elf . map . list . Hex file
Symbolic representation of functions in deep learning papers
單片機藍牙無線燒錄
Classification, understanding and application of common methods of JS array
Knowledge summary of request
程序设计大作业:教务管理系统(C语言)
Stm32f1+bc20+mqtt+freertos system is connected to Alibaba cloud to transmit temperature and humidity and control LED lights
Remember an experience of ECS being blown up by passwords - closing a small black house, changing passwords, and changing ports
Walk into WPF's drawing Bing Dwen Dwen
arduino获取随机数
JS variable types and common type conversions
MySQL time, time zone, auto fill 0
MySQL replacement field part content
2022.2.12 resumption
Reno7 60W super flash charging architecture
Oppo vooc fast charging circuit and protocol
Gravure sans fil Bluetooth sur micro - ordinateur à puce unique
Keyword inline (inline function) usage analysis [C language]
Cannot change version of project facet Dynamic Web Module to 2.3.