regex - 在 PowerShell 中使用正则表达式替换多行字符串
问题描述
我正在尝试实现这一点,但它在 Notepad++ 中工作,但在 PowerShell+regex 中没有
文件:1.txt
1
2
3
4
PS:
(Get-Content E:\1.txt).replace("(?ms)1((?:.*\r?\n?)*)4", "success") | Set-Content E:\2.txt
我试过用?ms、?s 和?m。
有什么帮助吗?
解决方案
推荐阅读
- python - datetime 在输出中返回 '
- javascript - 如何修复视口中的滚动中心?
- python - 如何在 Tkinter 和 Matplotlib 中将日期时间对象格式化为可读标签?
- html - CSS属性中的@是什么?它是在网站代码中定义的?(示例-颜色:@fill;)
- amazon-s3 - localstack:aws cp 无法将文件上传到 S3 存储桶
- oracle-apex - 在 Oracle APEX 中聚焦时创建一个像“10,000.0000”这样的数字字段?
- elixir - 编译 en Elixir 程序时执行的函数
- python - 是否可以在 ipython 中始终运行事件循环,类似于在 jupyter notebook 中的操作方式?
- python - 为什么我用 SMTP Python 发送的消息是空的?
- java - 增强Java中数组中元素出现次数最多的方式