Flutter Dart: How to extract a number from a string using RegEx

后端 未结 3 1061
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-18 03:58

I want to extract a number (integer, decimal or 12:30 formats) from a string. I have used the following RegEx but to no avail:

final RegExp numberExp = new R         


        
3条回答
  •  无人共我
    2021-01-18 04:52

    For one-line strings you can simply use:

    final intValue = int.parse(stringValue.replaceAll(RegExp('[^0-9]'), ''));
    

提交回复
热议问题