is there a splitByCharacterType method in c# like there is in Java?

后端 未结 3 882
[愿得一人]
[愿得一人] 2021-01-23 16:05

In Java there is a method splitByCharacterType that takes a string, for example 0015j8*(, and split it into \"0015\",\"j\",\"8\",\"*\",\"(\". Is there

3条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-23 16:21

    You could maybe use regex class, somthing like below, but you will need to add support for other chars other than numbers and letters.

       var chars = Regex.Matches("0015j8*(", @"((?:""[^""\\]*(?:\\.[^""\\]*)*"")|[a-z]|\d+)").Cast().Select(match => match.Value).ToArray(); 
    

    Result 0015,J,8

提交回复
热议问题