当前位置:网站首页>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);
}
边栏推荐
- Amba, ahb, APB, Axi Understanding
- MySQL占用内存过大解决方案
- Vscode basic configuration
- Kaggle competition two Sigma connect: rental listing inquiries
- ESP learning problem record
- Stm32f1+bc20+mqtt+freertos system is connected to Alibaba cloud to transmit temperature and humidity and control LED lights
- NRF24L01 troubleshooting
- Redis based distributed locks and ultra detailed improvement ideas
- Cannot change version of project facet Dynamic Web Module to 2.3.
- Embedded startup process
猜你喜欢
I2C bus timing explanation
Learning notes of JS variable scope and function
Types de variables JS et transformations de type communes
JS 函数提升和var变量的声明提升
JS数组常用方法的分类、理解和运用
(一)R语言入门指南——数据分析的第一步
程序员老鸟都会搞错的问题 C语言基础 指针和数组
Stm32f1+bc20+mqtt+freertos system is connected to Alibaba cloud to transmit temperature and humidity and control LED lights
History object
Feature of sklearn_ extraction. text. CountVectorizer / TfidVectorizer
随机推荐
VSCode基础配置
(四)R语言的数据可视化——矩阵图、柱状图、饼图、散点图与线性回归、带状图
Pytoch temperature prediction
Common properties of location
Arduino get random number
列表的使用
[leetcode19]删除链表中倒数第n个结点
Priority inversion and deadlock
程序员老鸟都会搞错的问题 C语言基础 指针和数组
Variable parameter principle of C language function: VA_ start、va_ Arg and VA_ end
Dead loop in FreeRTOS task function
Kaggle competition two Sigma connect: rental listing inquiries (xgboost)
Kconfig Kbuild
The dolphin scheduler remotely executes shell scripts through the expect command
Who says that PT online schema change does not lock the table, or deadlock
Feature of sklearn_ extraction. text. CountVectorizer / TfidVectorizer
嵌入式启动流程
Classification, understanding and application of common methods of JS array
A possible cause and solution of "stuck" main thread of RT thread
Esp8266 connect onenet (old mqtt mode)