我的努力:我試着看類似的問題,但我無法弄清楚我的答案。我也嘗試使用網絡(https://www.cheatography.com/davechild/cheat-sheets/regular-expressions/)自己弄清楚這一點,但我不能得到正確的答案。使用myString.replaceAll("_.+/[^.]*/", "");
使用正則表達式java替換某個字符前後的字符串
試過我有一個字符串:String myString = "hello_AD123.mp3";
而且我想用正則表達式的Java爲了下劃線(包括IT)和(MP3播放)之前停止後刪除所有內容。我將如何做到這一點?
所以我想最終的結果是以下幾點:myString = "hello.mp3";
'myString = myString.replaceFirst(「_ [^。] *」,「」);' –
打我吧,很好 – dambros
它確實刪除,我剛剛試過。 – dambros