1.javaçreplaceFirst
javaçreplaceFirst
æ¥éçè¡ä½ å¯ä»¥è·è¿å»çä¸æºç ï¼
å®çæºç æ¯è¿æ ·çï¼
int cursor = 0;
char nextChar = replacement.charAt(cursor);
if (nextChar == '\\') {
cursor++;
nextChar = replacement.charAt(cursor);
result.append(nextChar);
cursor++;
å ¶ä¸replacement为"\\",码分github线程池源码å¼å§è¿ä¸ªnextChar ä¼å¾å°æ¯'\'ï¼å ¶å®æ¯'\\'å®==â\\âï¼è¿å ¥æ¡ä»¶ï¼å次æ§è¡
replacement.charAt(1)çæ¶åæ¥éãå 为å符串"\\".length()æ¯1ï¼æ以è¶çäºãä½ æ³æ¿æ¢æ"\"éè¦æ¹æSystem.out.println("?".replaceFirst("\\?", "\\\\"));
2024-12-22 09:07
2024-12-22 08:35
2024-12-22 08:12
2024-12-22 07:36
2024-12-22 07:36
2024-12-22 07:12