PowerShell默认按每一行遍历去匹配模式

比如“aaa`nbbb”用“a.*b”是匹配不到的

需要用“(?s)a.*b”来匹配

1. Search

$ret = "test string" -Match "pattern"

$ret 为true时匹配成功,捕获的值用$Matches获取。

2. Replace

$result = "Test string" -Replace "Pattern", "Target string"

当pattent里有捕获时, Target string 用 $1, $2 ... 引用

?<=是正向查找,它与主表达式之前的组匹配,而不包含在结果中

?=是正向超前,它与主表达式后的组匹配,但不将其包括在结果中

样例

https://www.cnblogs.com/MerLin-LiuNian/p/15308860.html

PowerShell Regex的更多相关文章

  1. 分享原创powershell脚本小工具ctracert.ps1

    ----------[脚本介绍]----------- 脚本名称:ctracert.ps1软件名称:灰主牛 跟踪路由 归属地版 V1.0脚本作用:1跟踪路由.2显示归属地.(注意不带显示时间功能)脚本 ...

  2. PowerShell实现文件下载(类wget)

    对Linux熟悉的读者可能会对Linux通过wget下载文件有印象,这个工具功能很强大,在.NET环境下提到下载文件大多数人熟悉的是通过System.Net.WebClient进行下载,这个程序集能实 ...

  3. Powershell变量的类型

    Powershell 默认支持的.NET类型如下:   [order], [pscustomobject], [array], [bool], [byte], [char], [datetime], ...

  4. PowerShell随笔2_分支 选择 循环 特殊变量

    PowerShell特殊变量: PowerShell的特殊变量由系统自动创建.用户自定义的变量名称应该不和特殊变量相同. $^ :前一命令行的第一个标记 $$ :前一命令行的最后一个标记 $_ :表示 ...

  5. Powershell Switch 条件

    Powershell Switch 条件 6 21 1月, 2012  在 Powershell tagged Powershell教程/ 分支/ 字符串/ 数字/ 条件by Mooser Lee 本 ...

  6. Powershell变量的类型和强类型

    Powershell变量的类型和强类型12 12月, 2011  在 Powershell  tagged Powershell教程 / 变量 / 存储 / 数据 / 类型 by Mooser Lee ...

  7. Windows PowerShell是啥?看完本文你就懂它了

    这篇文章主要介绍了Windows PowerShell是啥?Windows PowerShell是什么?Windows PowerShell有哪些特性?Windows PowerShell有什么用?看 ...

  8. Windows PowerShell基本语法及常用命令

    PowerShell常用命令: 一 Get类 1.Get-Command : 得到所有PowerShell命令,获取有关 cmdlet 以及有关 Windows PowerShell 命令的其他元素的 ...

  9. Windows PowerShell 入門(5)-制御構文

    Windows PowerShellにおける制御構文について学びます.数ある制御構文の中でもSwitch文は.他の言語に比べ豊富な機能が用意されています. 対象読者 Windows PowerShel ...

  10. win7 powershell配色方案

    首先我是参考微软的word的, look~ Windows PowerShell 配置文件 要配置powershell很简单, 就几步 1.显示 Windows PowerShell 配置文件的路径 ...

随机推荐

  1. 无法加载 DLL“*******.dll”: 找不到指定的模块。 (异常来自 HRESULT:0x8007007E)。

    无法加载 DLL"Lib\WeWorkFinanceSdk.dll": 找不到指定的模块. (异常来自 HRESULT:0x8007007E). 网上查找了一大堆,没找到是什么问题 ...

  2. pycharm软件的基本使用、python的注释语法、变量与常量、变量的命名风格、垃圾回收机制、数据类型、数据类型之整型、数据类型之浮点型

    一.pycharm软件的基本使用 修改主题背景 修改字体大小 切换解释器 如何新建python文件 创建后缀是py的文件 注意:pycharm的语言 一定要使用英文的 二.python语法注释 (1) ...

  3. Zookeeper+SpringCloud微服务(入门二)

    1.Zookeeper注册中心 1.服务提供者Provider 新建cloud-provider-zk-payment-8004 pom.xml: <dependencies> <d ...

  4. 罗姆BU32107EFV缩写词

    ADC Analog-to-Digital Converter Att Attenuation 衰减 AMix Analog Mixing AVol Analog Volume BPF Band-Pa ...

  5. 原生微信小程序跳转传参 : [非TabBar跳转传参] 和 [TabBar跳转传参]

    一般常用的微信小程序跳转分为两种 1.非TabBar跳转 2.TabBar跳转 1.非TabBar跳转 非TabBar页面的跳转通常使用wx.navigateTo来跳转页面,在链接后面加 ? 传参,如 ...

  6. U-Boot-基础概念与学习分享

    U-Boot 基础概念与学习分享 Board: rockchip-px30, armv8, Cortex-A35 U-Boot: rockchip-linux/u-boot, branch next- ...

  7. Solon2 与 Spring Boot 的区别

    1.与 Springboot 的常用注解比较 Solon 2.2.0 Springboot 2.7.8 说明 @Inject * @Autowired 注入Bean(by type) @Inject( ...

  8. LeetCode-1610 可见点的最大数目

    来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/maximum-number-of-visible-points 题目描述 给你一个点数组 poi ...

  9. mkdir 08 权限居然和mkdir 07不同

    在用fileZilla软件往Ubuntu传输文件时,提示没有权限,当时就蒙了,往文件夹复制内容怎么还扯到权限了?ls -l一看,mkdir 08 权限居然和mkdir 07不同,记录下来. 原因:在嵌 ...

  10. python去重的几种方法

    from collections import OrderedDict list1 = [1,5,2,1,10] print(list(set(list1))) #[1, 2, 10, 5] 这种方式 ...