/// <summary> /// 将"yyyy-MM-dd HH:mm:ss"格式的字符串转为"//Date(1294499956278+0800)//"格式 /// </summary> /// <param name="jsonString"></param> /// <returns></returns> public static string JsonDeserialize(string jsonString) { string p = @"(\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2})"; System.Text.RegularExpressions.MatchEvaluator matchEvaluator = new System.Text.RegularExpressions.MatchEvaluator(ConvertDateStringToJsonDate); System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(p); string c = reg.Replace(jsonString, matchEvaluator); return(c); }
/// <summary> /// /// </summary> /// <typeparam name="T"></typeparam> /// <param name="model"></param> /// <returns></returns> public string GetJson <T>(T model) { JavaScriptSerializer jss = new JavaScriptSerializer(); string jsonString = jss.Serialize(model); string p = @"\\/Date\((\d+)\)\\/"; System.Text.RegularExpressions.MatchEvaluator matchEvaluator = new System.Text.RegularExpressions.MatchEvaluator(this.ConvertJsonDateToDateString); System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(p); jsonString = reg.Replace(jsonString, matchEvaluator); return(jsonString); }
public static Delegate System_Text_RegularExpressions_MatchEvaluator(LuaFunction func) { System.Text.RegularExpressions.MatchEvaluator d = (param0) => { int top = func.BeginPCall(); IntPtr L = func.GetLuaState(); LuaScriptMgr.PushObject(L, param0); func.PCall(top, 1); object[] objs = func.PopValues(top); func.EndPCall(top); return((string)objs[0]); }; return(d); }
public static string UrlEncode(string s) { System.Text.RegularExpressions.MatchEvaluator me = new System.Text.RegularExpressions.MatchEvaluator(jsConnect.StrUpper); string result = HttpUtility.UrlEncode(s); result = System.Text.RegularExpressions.Regex.Replace(result, "%[0-9a-f][0-9a-f]", me); result = result.Replace("'", "%27"); result = result.Replace("!", "%21"); result = result.Replace("*", "%2A"); result = result.Replace("(", "%28"); result = result.Replace(")", "%29"); return(result); }
public static bool _Replace_System_Text_RegularExpressions_Regex_System_String_System_Text_RegularExpressions_MatchEvaluator_System_Int32_System_Int32( ) { //Parameters System.String input = null; System.Text.RegularExpressions.MatchEvaluator evaluator = null; System.Int32 count = null; System.Int32 startat = null; //ReturnType/Value System.String returnVal_Real = null; System.String returnVal_Intercepted = null; //Exception Exception exception_Real = null; Exception exception_Intercepted = null; InterceptionMaintenance.disableInterception( ); try { returnValue_Real = System.Text.RegularExpressions.Regex.Replace(input, evaluator, count, startat); } catch (Exception e) { exception_Real = e; } InterceptionMaintenance.enableInterception( ); try { returnValue_Intercepted = System.Text.RegularExpressions.Regex.Replace(input, evaluator, count, startat); } catch (Exception e) { exception_Intercepted = e; } Return((exception_Real.Messsage == exception_Intercepted.Message) && (returnValue_Real == returnValue_Intercepted)); }
static internal int checkDelegate(IntPtr l, int p, out System.Text.RegularExpressions.MatchEvaluator ua) { int op = extractFunction(l, p); if (LuaDLL.lua_isnil(l, p)) { ua = null; return(op); } else if (LuaDLL.lua_isuserdata(l, p) == 1) { ua = (System.Text.RegularExpressions.MatchEvaluator)checkObj(l, p); return(op); } if (LuaDLL.lua_isnil(l, -1)) { ua = null; return(op); } LuaDelegate ld; checkType(l, -1, out ld); LuaDLL.lua_pop(l, 1); if (ld.d != null) { ua = (System.Text.RegularExpressions.MatchEvaluator)ld.d; return(op); } l = LuaState.get(l).L; ua = (System.Text.RegularExpressions.Match a1) => { int error = pushTry(l); pushValue(l, a1); ld.pcall(1, error); string ret; checkType(l, error + 1, out ret); LuaDLL.lua_settop(l, error - 1); return(ret); }; ld.d = ua; return(op); }
/// <summary> /// Decodes the text of a URI by unescaping any percent-encoded character sequences and /// then evaluating the result using the specified encoding. /// </summary> /// <param name="text">The encoded URI.</param> /// <param name="encoding">The encoding to use for Unicode characters in the URI. If this value is <see langword="null"/>, the <see cref="Encoding.UTF8"/> encoding will be used.</param> /// <returns>The decoded URI text.</returns> /// <exception cref="ArgumentNullException">If <paramref name="text"/> is <see langword="null"/>.</exception> public static string UriDecode(string text, Encoding encoding) { if (text == null) { throw new ArgumentNullException("text"); } encoding = encoding ?? Encoding.UTF8; MatchEvaluator matchEvaluator = match => { string hexValue = match.Value.Substring(1); return(((char)byte.Parse(hexValue, NumberStyles.HexNumber)).ToString()); }; string decodedText = _percentEncodedPattern.Replace(text, matchEvaluator); byte[] data = decodedText.ToCharArray().ConvertAll(c => (byte)c); return(encoding.GetString(data, 0, data.Length)); }
static StackObject *Replace_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 3); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.Text.RegularExpressions.MatchEvaluator @evaluator = (System.Text.RegularExpressions.MatchEvaluator) typeof(System.Text.RegularExpressions.MatchEvaluator).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); System.String @input = (System.String) typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 3); System.Text.RegularExpressions.Regex instance_of_this_method = (System.Text.RegularExpressions.Regex) typeof(System.Text.RegularExpressions.Regex).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); var result_of_this_method = instance_of_this_method.Replace(@input, @evaluator); return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method)); }
public string Replace(string input, System.Text.RegularExpressions.MatchEvaluator evaluator, int count, int startat) { throw null; }
public static string Replace(string input, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute("Regex", "options")] string pattern, System.Text.RegularExpressions.MatchEvaluator evaluator, System.Text.RegularExpressions.RegexOptions options, System.TimeSpan matchTimeout) { throw null; }
public string Replace(string input, System.Text.RegularExpressions.MatchEvaluator evaluator) { throw null; }
public static string Replace(string input, string pattern, System.Text.RegularExpressions.MatchEvaluator evaluator, System.Text.RegularExpressions.RegexOptions options, System.TimeSpan matchTimeout) { throw null; }
public static string Replace(string input, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute("Regex")] string pattern, System.Text.RegularExpressions.MatchEvaluator evaluator) { throw null; }
public string Replace(string input, System.Text.RegularExpressions.MatchEvaluator evaluator, int count, int startat) { return(default(string)); }
public static string UrlEncode(string s) { System.Text.RegularExpressions.MatchEvaluator me = new System.Text.RegularExpressions.MatchEvaluator(jsConnect.StrUpper); string result = HttpUtility.UrlEncode(s); result = System.Text.RegularExpressions.Regex.Replace(result, "%[0-9a-f][0-9a-f]", me); result = result.Replace("'", "%27"); result = result.Replace("!", "%21"); result = result.Replace("*", "%2A"); result = result.Replace("(", "%28"); result = result.Replace(")", "%29"); return result; }
public static string Replace(string input, string pattern, System.Text.RegularExpressions.MatchEvaluator evaluator) { return(default(string)); }
public static string Replace(string input, string pattern, System.Text.RegularExpressions.MatchEvaluator evaluator, System.Text.RegularExpressions.RegexOptions options, System.TimeSpan matchTimeout) { return(default(string)); }
public string Replace(string input, System.Text.RegularExpressions.MatchEvaluator evaluator, int count) { }
/// <summary> /// <see cref="System.Text.RegularExpressions.Regex.Replace(string, string, System.Text.RegularExpressions.MatchEvaluator, System.Text.RegularExpressions.RegexOptions, TimeSpan)" /> のラップメソッドを提供します。 /// </summary> /// <param name="value">インスタンス。</param> /// <param name="pattern">正規表現パターン。</param> /// <param name="evaluator">置換カスタムメソッド。</param> /// <param name="options">一致オプション。</param> /// <param name="matchTimeout">タイムアウト期間。</param> /// <returns> /// 置換後の文字列を返却します。 /// </returns> public static string RegReplace(this string value, string pattern, System.Text.RegularExpressions.MatchEvaluator evaluator, System.Text.RegularExpressions.RegexOptions options, TimeSpan matchTimeout) { return(System.Text.RegularExpressions.Regex.Replace(value, pattern, evaluator, options, matchTimeout)); }
static int Replace(IntPtr L) { int count = LuaDLL.lua_gettop(L); if (count == 3 && LuaScriptMgr.CheckTypes(L, 1, typeof(System.Text.RegularExpressions.Regex), typeof(string), typeof(System.Text.RegularExpressions.MatchEvaluator))) { System.Text.RegularExpressions.Regex obj = (System.Text.RegularExpressions.Regex)LuaScriptMgr.GetNetObjectSelf(L, 1, "System.Text.RegularExpressions.Regex"); string arg0 = LuaScriptMgr.GetString(L, 2); System.Text.RegularExpressions.MatchEvaluator arg1 = null; LuaTypes funcType3 = LuaDLL.lua_type(L, 3); if (funcType3 != LuaTypes.LUA_TFUNCTION) { arg1 = (System.Text.RegularExpressions.MatchEvaluator)LuaScriptMgr.GetLuaObject(L, 3); } else { LuaFunction func = LuaScriptMgr.GetLuaFunction(L, 3); arg1 = (param0) => { int top = func.BeginPCall(); LuaScriptMgr.PushObject(L, param0); func.PCall(top, 1); object[] objs = func.PopValues(top); func.EndPCall(top); return((string)objs[0]); }; } string o = obj.Replace(arg0, arg1); LuaScriptMgr.Push(L, o); return(1); } else if (count == 3 && LuaScriptMgr.CheckTypes(L, 1, typeof(System.Text.RegularExpressions.Regex), typeof(string), typeof(string))) { System.Text.RegularExpressions.Regex obj = (System.Text.RegularExpressions.Regex)LuaScriptMgr.GetNetObjectSelf(L, 1, "System.Text.RegularExpressions.Regex"); string arg0 = LuaScriptMgr.GetString(L, 2); string arg1 = LuaScriptMgr.GetString(L, 3); string o = obj.Replace(arg0, arg1); LuaScriptMgr.Push(L, o); return(1); } else if (count == 3 && LuaScriptMgr.CheckTypes(L, 1, typeof(string), typeof(string), typeof(string))) { string arg0 = LuaScriptMgr.GetString(L, 1); string arg1 = LuaScriptMgr.GetString(L, 2); string arg2 = LuaScriptMgr.GetString(L, 3); string o = System.Text.RegularExpressions.Regex.Replace(arg0, arg1, arg2); LuaScriptMgr.Push(L, o); return(1); } else if (count == 3 && LuaScriptMgr.CheckTypes(L, 1, typeof(string), typeof(string), typeof(System.Text.RegularExpressions.MatchEvaluator))) { string arg0 = LuaScriptMgr.GetString(L, 1); string arg1 = LuaScriptMgr.GetString(L, 2); System.Text.RegularExpressions.MatchEvaluator arg2 = null; LuaTypes funcType3 = LuaDLL.lua_type(L, 3); if (funcType3 != LuaTypes.LUA_TFUNCTION) { arg2 = (System.Text.RegularExpressions.MatchEvaluator)LuaScriptMgr.GetLuaObject(L, 3); } else { LuaFunction func = LuaScriptMgr.GetLuaFunction(L, 3); arg2 = (param0) => { int top = func.BeginPCall(); LuaScriptMgr.PushObject(L, param0); func.PCall(top, 1); object[] objs = func.PopValues(top); func.EndPCall(top); return((string)objs[0]); }; } string o = System.Text.RegularExpressions.Regex.Replace(arg0, arg1, arg2); LuaScriptMgr.Push(L, o); return(1); } else if (count == 4 && LuaScriptMgr.CheckTypes(L, 1, typeof(System.Text.RegularExpressions.Regex), typeof(string), typeof(string), typeof(int))) { System.Text.RegularExpressions.Regex obj = (System.Text.RegularExpressions.Regex)LuaScriptMgr.GetNetObjectSelf(L, 1, "System.Text.RegularExpressions.Regex"); string arg0 = LuaScriptMgr.GetString(L, 2); string arg1 = LuaScriptMgr.GetString(L, 3); int arg2 = (int)LuaDLL.lua_tonumber(L, 4); string o = obj.Replace(arg0, arg1, arg2); LuaScriptMgr.Push(L, o); return(1); } else if (count == 4 && LuaScriptMgr.CheckTypes(L, 1, typeof(System.Text.RegularExpressions.Regex), typeof(string), typeof(System.Text.RegularExpressions.MatchEvaluator), typeof(int))) { System.Text.RegularExpressions.Regex obj = (System.Text.RegularExpressions.Regex)LuaScriptMgr.GetNetObjectSelf(L, 1, "System.Text.RegularExpressions.Regex"); string arg0 = LuaScriptMgr.GetString(L, 2); System.Text.RegularExpressions.MatchEvaluator arg1 = null; LuaTypes funcType3 = LuaDLL.lua_type(L, 3); if (funcType3 != LuaTypes.LUA_TFUNCTION) { arg1 = (System.Text.RegularExpressions.MatchEvaluator)LuaScriptMgr.GetLuaObject(L, 3); } else { LuaFunction func = LuaScriptMgr.GetLuaFunction(L, 3); arg1 = (param0) => { int top = func.BeginPCall(); LuaScriptMgr.PushObject(L, param0); func.PCall(top, 1); object[] objs = func.PopValues(top); func.EndPCall(top); return((string)objs[0]); }; } int arg2 = (int)LuaDLL.lua_tonumber(L, 4); string o = obj.Replace(arg0, arg1, arg2); LuaScriptMgr.Push(L, o); return(1); } else if (count == 4 && LuaScriptMgr.CheckTypes(L, 1, typeof(string), typeof(string), typeof(string), typeof(System.Text.RegularExpressions.RegexOptions))) { string arg0 = LuaScriptMgr.GetString(L, 1); string arg1 = LuaScriptMgr.GetString(L, 2); string arg2 = LuaScriptMgr.GetString(L, 3); System.Text.RegularExpressions.RegexOptions arg3 = (System.Text.RegularExpressions.RegexOptions)LuaScriptMgr.GetLuaObject(L, 4); string o = System.Text.RegularExpressions.Regex.Replace(arg0, arg1, arg2, arg3); LuaScriptMgr.Push(L, o); return(1); } else if (count == 4 && LuaScriptMgr.CheckTypes(L, 1, typeof(string), typeof(string), typeof(System.Text.RegularExpressions.MatchEvaluator), typeof(System.Text.RegularExpressions.RegexOptions))) { string arg0 = LuaScriptMgr.GetString(L, 1); string arg1 = LuaScriptMgr.GetString(L, 2); System.Text.RegularExpressions.MatchEvaluator arg2 = null; LuaTypes funcType3 = LuaDLL.lua_type(L, 3); if (funcType3 != LuaTypes.LUA_TFUNCTION) { arg2 = (System.Text.RegularExpressions.MatchEvaluator)LuaScriptMgr.GetLuaObject(L, 3); } else { LuaFunction func = LuaScriptMgr.GetLuaFunction(L, 3); arg2 = (param0) => { int top = func.BeginPCall(); LuaScriptMgr.PushObject(L, param0); func.PCall(top, 1); object[] objs = func.PopValues(top); func.EndPCall(top); return((string)objs[0]); }; } System.Text.RegularExpressions.RegexOptions arg3 = (System.Text.RegularExpressions.RegexOptions)LuaScriptMgr.GetLuaObject(L, 4); string o = System.Text.RegularExpressions.Regex.Replace(arg0, arg1, arg2, arg3); LuaScriptMgr.Push(L, o); return(1); } else if (count == 5 && LuaScriptMgr.CheckTypes(L, 1, typeof(System.Text.RegularExpressions.Regex), typeof(string), typeof(string), typeof(int), typeof(int))) { System.Text.RegularExpressions.Regex obj = (System.Text.RegularExpressions.Regex)LuaScriptMgr.GetNetObjectSelf(L, 1, "System.Text.RegularExpressions.Regex"); string arg0 = LuaScriptMgr.GetString(L, 2); string arg1 = LuaScriptMgr.GetString(L, 3); int arg2 = (int)LuaDLL.lua_tonumber(L, 4); int arg3 = (int)LuaDLL.lua_tonumber(L, 5); string o = obj.Replace(arg0, arg1, arg2, arg3); LuaScriptMgr.Push(L, o); return(1); } else if (count == 5 && LuaScriptMgr.CheckTypes(L, 1, typeof(System.Text.RegularExpressions.Regex), typeof(string), typeof(System.Text.RegularExpressions.MatchEvaluator), typeof(int), typeof(int))) { System.Text.RegularExpressions.Regex obj = (System.Text.RegularExpressions.Regex)LuaScriptMgr.GetNetObjectSelf(L, 1, "System.Text.RegularExpressions.Regex"); string arg0 = LuaScriptMgr.GetString(L, 2); System.Text.RegularExpressions.MatchEvaluator arg1 = null; LuaTypes funcType3 = LuaDLL.lua_type(L, 3); if (funcType3 != LuaTypes.LUA_TFUNCTION) { arg1 = (System.Text.RegularExpressions.MatchEvaluator)LuaScriptMgr.GetLuaObject(L, 3); } else { LuaFunction func = LuaScriptMgr.GetLuaFunction(L, 3); arg1 = (param0) => { int top = func.BeginPCall(); LuaScriptMgr.PushObject(L, param0); func.PCall(top, 1); object[] objs = func.PopValues(top); func.EndPCall(top); return((string)objs[0]); }; } int arg2 = (int)LuaDLL.lua_tonumber(L, 4); int arg3 = (int)LuaDLL.lua_tonumber(L, 5); string o = obj.Replace(arg0, arg1, arg2, arg3); LuaScriptMgr.Push(L, o); return(1); } else { LuaDLL.luaL_error(L, "invalid arguments to method: System.Text.RegularExpressions.Regex.Replace"); } return(0); }
/// <summary> /// <see cref="System.Text.RegularExpressions.Regex.Replace(string, string, System.Text.RegularExpressions.MatchEvaluator)"/> のラップメソッドを提供します。 /// </summary> /// <param name="value">インスタンス。</param> /// <param name="pattern">正規表現パターン。</param> /// <param name="evaluator">置換カスタムメソッド。</param> /// <returns> /// 置換後の文字列を返却します。 /// </returns> /// <example> /// <code language="C#" numberLines="true"> /// // マッチした文字列に対してカスタムメソッドで置換 /// var s1 = "abcABCabc"; /// var s2 = s1.RegReplace("[a-z]", m => { return $"{m.Value}{m.Value}"; }; /// /// // s2: aabbccABCaabbcc /// </code> /// </example> public static string RegReplace(this string value, string pattern, System.Text.RegularExpressions.MatchEvaluator evaluator) { return(System.Text.RegularExpressions.Regex.Replace(value, pattern, evaluator)); }
// // Summary: // In a specified input string, replaces a specified maximum number of strings that // match a regular expression pattern with a string returned by a System.Text.RegularExpressions.MatchEvaluator // delegate. // // Parameters: // input: // The string to search for a match. // // evaluator: // A custom method that examines each match and returns either the original matched // string or a replacement string. // // count: // The maximum number of times the replacement will occur. // // Returns: // A new string that is identical to the input string, except that a replacement // string takes the place of each matched string. If the regular expression pattern // is not matched in the current instance, the method returns the current instance // unchanged. // // Exceptions: // T:System.ArgumentNullException: // input or evaluator is null. // // T:System.Text.RegularExpressions.RegexMatchTimeoutException: // A time-out occurred. For more information about time-outs, see the Remarks section. public string Replace(string input, System.Text.RegularExpressions.MatchEvaluator evaluator, int count) => performanceObject.Replace(input, evaluator, count);