2

文字列があり、フレーズの前にあるものをすべて削除してから、別のフレーズの後にあるものをすべて削除したいと考えています。つまり、

myString = "words words words FIRSTPHRASE these words I want SECONDPHRASE but not these words"

したがって、新しい文字列は"these words I want".

4

2 に答える 2

1

このようなもの?

string theWordsIWant = Regex.Replace(myString, @"^.*?FIRSTPHRASE\s*(.*?)\s*SECONDPHRASE.*$", "$1");

Demonstration

于 2013-10-27T22:41:04.237 に答える