娱乐一下:- $s = @'
- hello11world
- -
- hello2go
- >
- world5to
-
-
-
- @hello
- hello
-
- @world
- world
- '@
-
- $a='添加字符串';
-
- [regex]::Replace($s, '(?s)^[^@]+', {
- if([string]::IsNullOrEmpty($args.Value.Trim())){return $args.Value;}
- [int[]]$num=[regex]::Matches($args.Value, '\d+').Value;
- $n=1;
- while($true){if($num -ne$null -and$num.Contains($n)){$n++}else{break;}}
- return "{0}`r`n$a$n`r`n`r`n" -f$args.Value.TrimEnd();
- })
复制代码
|