Is there an equivalent to 'sscanf()' in .NET?

后端 未结 8 1541
故里飘歌
故里飘歌 2020-12-10 11:46

The .NET Framework gives us the Format method:

string s = string.Format(\"This {0} very {1}.\", \"is\", \"funny\");
// s is now: \"This is very funny.\"
         


        
8条回答
  •  春和景丽
    2020-12-10 12:23

    I reference earlier reply, wrote a sample see following

    string sampleinput = "FirstWord.22222";
    
    Match match = Regex.Match(sampleinput, @"(\w+)\.(\d+)$", RegexOptions.IgnoreCase);
    
    if(match.Success){
    
        string totalmatchstring = match.Groups[0]; // FirstWord.22222
        string firstpart = match.Groups[1]; // FirstWord`
        string secondpart = match.Groups[2]; // 22222
    
    }
    

提交回复
热议问题