UseSubstitutions
FindReplaceOptions.UseSubstitutions property
Değiştirme kalıpları içindeki ikamelerin tanınıp tanınmayacağını ve kullanılıp kullanılmayacağını belirten bir boole değeri alır veya ayarlar. Varsayılan değer şudur:yanlış
.
public bool UseSubstitutions { get; set; }
Notlar
Yerine koyma öğeleriyle ilgili ayrıntılar için lütfen şu adrese bakın: https://docs.microsoft.com/en-us/dotnet/standard/base-types/substitutions-in-regular-expressions.
Örnekler
Değiştirme kalıplarında yer değiştirmelerin nasıl tanınacağını ve kullanılacağını gösterir.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.Write("Jason gave money to Paul.");
Regex regex = new Regex(@"([A-z]+) gave money to ([A-z]+)");
FindReplaceOptions options = new FindReplaceOptions();
options.UseSubstitutions = true;
// Eski modu kullanmak pek çok gelişmiş özelliği desteklemez, bu yüzden onu 'false' olarak ayarlamamız gerekiyor.
options.LegacyMode = false;
doc.Range.Replace(regex, @"$2 took money from $1", options);
Assert.AreEqual(doc.GetText(), "Paul took money from Jason.\f");
Metnin ikamelerle nasıl değiştirileceğini gösterir.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.Writeln("John sold a car to Paul.");
builder.Writeln("Jane sold a house to Joe.");
// Bul ve değiştir işlemini değiştirmek için bir "FindReplaceOptions" nesnesi kullanabiliriz.
FindReplaceOptions options = new FindReplaceOptions();
// Almak için "UseSubstitutions" özelliğini "true" olarak ayarlayın
// ikame öğelerini tanımak için bul ve değiştir işlemi.
// Değiştirme öğelerini yok saymak için "UseSubstitutions" özelliğini "false" olarak ayarlayın.
options.UseSubstitutions = useSubstitutions;
Regex regex = new Regex(@"([A-z]+) sold a ([A-z]+) to ([A-z]+)");
doc.Range.Replace(regex, @"$3 bought a $2 from $1", options);
Assert.AreEqual(
useSubstitutions
? "Paul bought a car from John.\rJoe bought a house from Jane."
: "$3 bought a $2 from $1.\r$3 bought a $2 from $1.", doc.GetText().Trim());
Ayrıca bakınız
- class FindReplaceOptions
- ad alanı Aspose.Words.Replacing
- toplantı Aspose.Words