我有以下文字:
{FFFFFF}Fe8uOywfW {EE9911}will
{FFFFFF}CV36LXRa {EE9911}will
{FFFFFF}lqtm {EE9911}will
{FFFFFF}2bCepDTJ {EE9911}will
{FFFFFF}cOu1bcaRT {EE9911}will
{FFFFFF}VbspL1XK {EE9911}will
{FFFFFF}your name {EE9911}will
{FFFFFF}NNXUELTq {EE9911}will
{FFFFFF}go to hill kide {EE9911}will
{FFFFFF}OJpbD2G1Y {EE9911}will
{FFFFFF}run noob {EE9911}will
{FFFFFF}fluffy {EE9911}will
我需要使用正则表达式来获取“{FFFFFF}”和“{EE9911}将”之间的所有内容,以及Fe8uOywfW,CV36LXRa等。我尝试过很多变种,但都没有。 (使用RegexMagic构建)
答案 0 :(得分:1)
如果没有关于你所做的事情的更多背景,并且不想匹配:
\{FFFFFF\}(.*)\{EE9911\}will
例如:
var s = @"{FFFFFF}Fe8uOywfW {EE9911}will
{FFFFFF}CV36LXRa {EE9911}will
{FFFFFF}lqtm {EE9911}will
{FFFFFF}2bCepDTJ {EE9911}will
{FFFFFF}cOu1bcaRT {EE9911}will
{FFFFFF}VbspL1XK {EE9911}will
{FFFFFF}your name {EE9911}will
{FFFFFF}NNXUELTq {EE9911}will
{FFFFFF}go to hill kide {EE9911}will
{FFFFFF}OJpbD2G1Y {EE9911}will
{FFFFFF}run noob {EE9911}will
{FFFFFF}fluffy {EE9911}will";
var r = new Regex(@"\{FFFFFF\}(.*)\{EE9911\}will");
foreach (Match m in r.Matches(s)) {
Console.WriteLine(m.Groups[1]); // Note: you might want to add
// some error checking here
}
输出:
Fe8uOywfW
CV36LXRa
lqtm
2bCepDTJ
cOu1bcaRT
VbspL1XK
your name
NNXUELTq
go to hill kide
OJpbD2G1Y
run noob
fluffy
答案 1 :(得分:0)
({F {6}})(+)({EE9911}会)
将它们分组并使用第二组
$ 2将提供所需的字符串