Universal Bible API 1.0.2011.1274
|
00001 using System; 00002 using System.Collections.Generic; 00003 using System.Linq; 00004 using System.Text; 00005 using System.Text.RegularExpressions; 00006 00007 namespace UniversalBibleAPI 00008 { 00012 public class RegExFilter : FilterDecorator 00013 { 00018 public string Pattern { get; set; } 00023 public string Replacement { get; set; } 00024 00025 public RegExFilter(IFilter otherFilter) : base(otherFilter) { } 00026 00032 public override string PerformFilter(string TextToFilter) 00033 { 00034 if (Pattern != null) 00035 { 00036 Regex RegEx = new Regex(Pattern); 00037 return RegEx.Replace(base.PerformFilter(TextToFilter), Replacement); 00038 } 00039 else { 00040 00041 return base.PerformFilter(TextToFilter); 00042 00043 } 00044 } 00045 } 00046 }