mz3*_*bel -3 c# regex regex-group regex-lookarounds uipath
我希望仅提取此“ =»”之后的数字,但我仍然保留其他一些文字:
[^»]*[\d{1,}]$
Run Code Online (Sandbox Code Playgroud)
> login as: LOGIN SERVER@00.00.00.000's password: Last login: Thu May 23
> 15:51:49 2019 from 00.00.00.000 CREER AUTANT DE REPERTOIRES SOUS
> /NAME/NAME/NAME QU'IL Y A DE COMMERCANTS GERES. LE NOM DOIT ETRE LE NO
> DE COMMERCANT. CREER ENSUITE SOUS CHACUN D'EUX UN REPERTOIRE NAME/
> <SERVER>ps -fu NAME | grep exe | echo «resultat=»`wc -l` «resultat=»14
> <SERVER>
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?
你的表情非常接近。我们可能只想将其=»作为左边界,然后使用a收集数字([0-9]+),这可能会起作用:
=»([0-9]+)
Run Code Online (Sandbox Code Playgroud)
如果不需要此表达式,则可以在regex101.com中对其进行修改或更改。
jex.im可视化正则表达式:
using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"=»([0-9]+)";
string input = @"> login as: LOGIN SERVER@00.00.00.000's password: Last login: Thu May 23
> 15:51:49 2019 from 00.00.00.000 CREER AUTANT DE REPERTOIRES SOUS
> /NAME/NAME/NAME QU'IL Y A DE COMMERCANTS GERES. LE NOM DOIT ETRE LE NO
> DE COMMERCANT. CREER ENSUITE SOUS CHACUN D'EUX UN REPERTOIRE NAME/
> <SERVER>ps -fu NAME | grep exe | echo «resultat=»`wc -l` «resultat=»14
> <SERVER>";
RegexOptions options = RegexOptions.Multiline;
foreach (Match m in Regex.Matches(input, pattern, options))
{
Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index);
}
}
}
Run Code Online (Sandbox Code Playgroud)
=»([0-9]+)
Run Code Online (Sandbox Code Playgroud)