regex - 正则表达式从不同格式的字符串中查找数字
问题描述
我有以下文字:
instance=hostname1, topic="AB_CD_EF_12345_ZY_XW_001_000001"
instance=hostname2, topic="AB_CD_EF_1345_ZY_XW_001_00001"
instance=hostname1, topic="AB_CD_EF_1235_ZY_XW_001_000001"
instance=hostname2, topic="AB_CD_EF_GH_4567_ZY_XW_01_000001"
instance=hostname1, topic="AB_CD_EF_35678_ZY_XW_001_00001"
instance=hostname2, topic="AB_CD_EF_56789_ZY_XW_001_000001"
我想从上面的示例中捕获数字。我尝试使用下面的正则表达式来做到这一点,它们可以很好地作为单独的查询:
Regex: *.topic="AB_CD_EF_([^_]+).*
Matches: 12345 1345 1235
Regex: *.topic="AB_CD_EF_GH_([^_]+).*
Matches: 4567 35678 56789
但我需要一个可以给我所有数字的正则表达式,即:
12345 1345 1235 4567 35678 56789
解决方案
推荐阅读
- visual-studio-code - 有没有办法在 BPMN Kogito 工具 VSCode 扩展上显示任务输入/输出?
- javascript - 同一用户在混合类型数组中对图像上传进行分组
- entity-framework - 当我不希望它时,EF Core 加载关系
- mysql - MYSQL 搜索 WHERE 值在 json_encoded 字段中
- mongodb - 如何使用 Debezium MongoDB Source Connector 将 JSON 值转换为 Kafka 消息键?
- tensorflow - tflite模型的反向转换
- excel - excel查找值并替换另一个单元格的值
- r - 如何解决在 R 上安装软件包的“写入错误”?
- spring-boot - Spring Boot 和 Spring Data Moore 发布
- c# - SmartCard 自定义凭据提供程序