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为"\\",码分青瓜影视APP源码å¼å§è¿ä¸ªnextChar ä¼å¾å°æ¯'\'ï¼å ¶å®æ¯'\\'å®==â\\âï¼è¿å ¥æ¡ä»¶ï¼å次æ§è¡
replacement.charAt(1)çæ¶åæ¥éãå 为å符串"\\".length()æ¯1ï¼æ以è¶çäºãä½ æ³æ¿æ¢æ"\"éè¦æ¹æSystem.out.println("?".replaceFirst("\\?", "\\\\"));