c# - 使用特定模式提取子字符串
问题描述
我需要提取一些我从另一个进程接收到的数据。接收到的内容在长度和格式上变化很大,但我需要一条信息始终采用相同的格式。
示例 1:
This is the first example (with a lot of content that I don't need) but the important piece of info is this: (test1 / jibberish)
示例 2:
This is another example (test2 / something I'm not interested in)
我感兴趣的唯一信息是一个始终具有相同模式的字符串
(信息/一些代码)
这只是我感兴趣的“信息”位。那么有什么东西(比如正则表达式?)我可以用来提取一个临时字符串(甚至可能没有括号),然后我可以在使用 / 时执行一个子字符串?
所以输出变成
info
谢谢
解决方案
在记事本++中我会查找:-\((.+?)\/.+
替换:-\1
推荐阅读
- python - CEWR Literals 的 Pylint 含义
- python - 将带有其他组件的不断更新的动画情节放在 tkinter gui 中
- amazon-linux - 在 Amazon Linux 上安装 fasd
- scala - 如何从控制台中删除 ASCII Spark Banner?
- php - 当未选中复选框时,我想显示数据库中的所有数据
- javascript - 具有放大缩放效果的无限旋转木马
- typescript - TypeScript 元组条件比较总是计算为 false
- reactjs - React 16 / Router V4中显示抽屉时如何覆盖后退按钮
- php - 如何修复 Yii2 中的“子目录中的静态页面”问题
- qt - 如果没有可用的模型数据,我可以用 Image 替换 SimpleRow