0
" testfile.txt #testfile.txt
My new message
Filename1.doC#filename.doc"
我怎樣才能找到文件名以「#」,並從字符串中刪除它
" testfile.txt #testfile.txt
My new message
Filename1.doC#filename.doc"
我怎樣才能找到文件名以「#」,並從字符串中刪除它
試試這個之一:
var pattern = @"\#[\w,\s-]+\.[A-Za-z]+\s*";
var result = Regex.Replace(
"testfile.txt #testfile.txt My new message Filename1.doC#filename.doc",
pattern, string.Empty);
結果:
"testfile.txt My new message Filename1.doc "
你的預期輸出是什麼? – 2015-03-31 03:02:56
我的輸出是: 「testfile.txt 我的新消息 Filename1.doc」 – Disha5 2015-03-31 03:05:37
是您的輸入是否包含換行符?試試'Regex.Replace(str,@「#\ S +」,「」);' – 2015-03-31 03:09:48