public override Content /*!*/ EscapeRegularExpression() { // TODO: var a = ToByteArray(); return(Create( BinaryEncoding.Instance.GetBytes(RubyRegex.Escape(BinaryEncoding.Instance.GetString(a, 0, a.Length))), _owner )); }
public static RubyRegex /*!*/ Union(ConversionStorage <MutableString> /*!*/ stringCast, ConversionStorage <IList> /*!*/ toAry, RubyClass /*!*/ self, [NotNull] object /*!*/ obj) { IList list = Protocols.TryCastToArray(toAry, obj); if (list != null) { return(Union(stringCast, list)); } // TODO: to_regexp RubyRegex regex = obj as RubyRegex; if (regex != null) { return(regex); } return(new RubyRegex(RubyRegex.Escape(Protocols.CastToString(stringCast, obj)), RubyRegexOptions.NONE)); }
private static RubyRegex /*!*/ Union(ConversionStorage <MutableString> /*!*/ stringCast, ICollection /*!*/ objs) { if (objs.Count == 0) { return(new RubyRegex(MutableString.CreateAscii("(?!)"), RubyRegexOptions.NONE)); } MutableString result = MutableString.CreateMutable(RubyEncoding.Binary); int i = 0; foreach (var obj in objs) { if (i > 0) { result.Append('|'); } // TODO: to_regexp RubyRegex regex = obj as RubyRegex; if (regex != null) { if (objs.Count == 1) { return(regex); } regex.AppendTo(result); } else { result.Append(RubyRegex.Escape(Protocols.CastToString(stringCast, obj))); } i++; } return(new RubyRegex(result, RubyRegexOptions.NONE)); }
public static RubyRegex /*!*/ Union(ConversionStorage <MutableString> /*!*/ stringCast, RubyClass /*!*/ self, params object[] /*!*/ strings) { if (strings.Length == 0) { return(new RubyRegex(MutableString.CreateAscii("(?!)"), RubyRegexOptions.NONE)); } MutableString result = MutableString.CreateMutable(RubyEncoding.Binary); for (int i = 0; i < strings.Length; i++) { if (i > 0) { result.Append('|'); } RubyRegex regex = strings[i] as RubyRegex; if (regex != null) { if (strings.Length == 1) { return(regex); } regex.AppendTo(result); } else { result.Append(RubyRegex.Escape(Protocols.CastToString(stringCast, strings[i]))); } } // TODO: //RubyClass regexClass = RubyUtils.GetExecutionContext(context).GetClass(typeof(RubyRegex)); //return NewCallSite3.Invoke(context, regexClass, result, null, null); return(new RubyRegex(result, RubyRegexOptions.NONE)); }
public static MutableString /*!*/ Escape(RubyClass /*!*/ self, [DefaultProtocol, NotNull] MutableString /*!*/ str) { return(RubyRegex.Escape(str).TaintBy(str)); }