在下面的代码中,为什么模式与正则表达式不匹配,但如果我使用正则表达式逐行读取12sep.txt文件,它是否正常工作?
string file = @"C:\Documents and Settings\Sandeep.kumar\Desktop\12sep.txt";
string filedta = File.ReadAllText(file);
string pattern = @"^[^\s]+.[^\s]txt$";
Regex rx = new Regex(pattern, RegexOptions.None);
MatchCollection mc = rx.Matches(filedta);
Run Code Online (Sandbox Code Playgroud) 我有一个字符串s"hello,sa n.txt"
但我希望字符串s ="hellosan.txt"没有逗号,没有空格,没有分号,应该在那里我怎么能在java中使用正则表达式?