[英]How can I find File name in string which start with # Using RegEx
我有字符串:
" 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 "
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.