参照帮助里的例子是这样嘛- Add-Type -TypeDefinition @'
- using System;
- using System.Text.RegularExpressions;
-
- public static class Cla
- {
- public static void Fun(string s1,string s2)
- {
- Regex rx = new Regex(s2);
- MatchCollection matches = rx.Matches(s1);
- Console.WriteLine(matches[0].Groups[0].Value);
- }
- }
- '@ -outputType library -outputAssembly ".\hello.dll"
-
- Add-Type -Path "$home\desktop\hello.dll"
- $s = "你好,世界!123"
- [cla]::Fun($s,'\d+')
复制代码
|