gpt4 book ai didi

c# - 从字符串请求中获取特定字符

转载 作者:太空宇宙 更新时间:2023-11-03 21:11:40 24 4
gpt4 key购买 nike

我需要从字符串中获取 4 个变量

这是某人可以向服务器发出的请求:

String request= "Jouer_un_bulletin <nbT> <mise> <numeros_grilleA> <numeros_grilleB>"

我需要获取 nbtmisenumeros_grilleAnumeros_grilleB

最佳答案

您可以尝试使用正则表达式:

  String request = "Jouer_un_bulletin <nbT> <mise> <numeros_grilleA> <numeros_grilleB>";

String pattern = @"(?<=<)[^<>]*(?=>)";

String[] prms = Regex
.Matches(request, pattern)
.OfType<Match>()
.Select(match => match.Value)
.ToArray();

测试:

  // nbT
// mise
// numeros_grilleA
// numeros_grilleB
Console.Write(String.Join(Environment.NewLine, prms));

关于c# - 从字符串请求中获取特定字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37214118/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com