Replacing file using regex

后端 未结 2 1552
北海茫月
北海茫月 2021-01-23 16:49

i tried to replace inner text of the month tag i.e month names should be replaced with their specified month number. i tried this,

 Dim strFile As String = File.         


        
2条回答
  •  南方客
    南方客 (楼主)
    2021-01-23 17:22

    Try this

    Dim y = "31Jan2011"
    
    Dim Match = Regex.Match(y, "([^>]*)<\/month>").Groups(1).ToString
    Regex.Replace(y, Match, DateTime.ParseExact(Match, "MMM", CultureInfo.CurrentCulture).Month.ToString)
    

    It will give you OP Like

    31012011
    

提交回复
热议问题