当前位置: 首页>>代码示例>>C#>>正文


C# String.Replace方法代码示例

本文整理汇总了C#中System.String.Replace方法的典型用法代码示例。如果您正苦于以下问题:C# String.Replace方法的具体用法?C# String.Replace怎么用?C# String.Replace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.String的用法示例。


在下文中一共展示了String.Replace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ConvertValue

 private static string ConvertValue(String value)
 {
     Dictionary<String, String> replacements = new Dictionary<string, string>();
     replacements.Add("&sp;", " ");
     replacements.Add("&1uc;", "{-|}");
     replacements.Add("&amp;", "&");
     replacements.Add("&bs;", "{# BackSpace}");
     replacements.Add("&cr;", "{# Return}");
     replacements.Add("&uc;", "{MODE:CAPS}");
     replacements.Add("&lc;", "{MODE:LOWER}");
     replacements.Add("&dw;", "{# Control_L(BackSpace)}");
     replacements.Add("\\", "\\\\");
     replacements.Add("\"", "\\\"");
     foreach (string key in replacements.Keys.OrderByDescending(_k=>_k.Length))
     {
         value = value.Replace(key, replacements[key]);
     }
     if (value.Contains("&+i;"))
     {
         value = String.Format("{0}{{^}}", value.Replace("&+i;", ""));
     }
     if (value.Contains("&rb;"))
     {
         value = String.Format("{{^}}{0}", value.Replace("&rb;", ""));
     }
     return value.Trim();
 }
开发者ID:Skaaal,项目名称:StenturaArduino,代码行数:27,代码来源:PloverEntry.cs

示例2: getLatFromAddress2

        public static String getLatFromAddress2(String s)
        {
            s = s.Replace("Suite", "");
            s = s.Replace("suite", "");
            s = s.Replace("Apt", "");
            s = s.Replace("apt", "");

            //Instance class use (Geocode)  (Can be made from static/instance class)
            var geocodeRequest = new GeocodingRequest
                                     {
                                         Address = s,
                                     };
            var geocodingEngine = new GeocodingEngine();

            GeocodingResponse geocode = geocodingEngine.GetGeocode(geocodeRequest);
            Result match1 = null;
            try
            {
                match1 = geocode.Results.First();
            }
            catch (Exception)
            {
                return "notfound";
            }
            Double lat = match1.Geometry.Location.Latitude;

            return lat.ToString();
        }
开发者ID:adowning,项目名称:codefirstmigrations,代码行数:28,代码来源:SMJobXMLParser.cs

示例3: changeGYBGPMWjm

        /// <summary>
        /// 修改已有的文件名。
        /// </summary>
        /// <param name="oldWjm">旧文件名</param>
        /// <param name="newWjm">新文件名</param>
        /// <returns>是否修改成功</returns>
        public bool changeGYBGPMWjm(String oldWjm, String newWjm)
        {
            if (null == oldWjm || null == newWjm)
            {
                return false;
            }

            String dwjm = newWjm.Replace(".PDF", ".DOC");

            IDictionary<String, Object> para = new Dictionary<String, Object>();
            para.Add("oldwjm", oldWjm);
            para.Add("newwjm", newWjm);
            para.Add("dwjm", dwjm);

            bool result = true;
            try
            {
                sqlMapper.Update("ChangeGYBG_PM_wjm", para);
                //修改PDF文件名
                OperationFile.ReNameFile(oldWjm, newWjm);
                //修改DOC文件名
                oldWjm=oldWjm.Replace(".PDF", ".DOC");
                newWjm=newWjm.Replace(".PDF", ".DOC");
                OperationFile.ReNameFile(oldWjm, newWjm);

            }
            catch
            {
                result = false;
            }
            return result;
        }
开发者ID:Brinews,项目名称:Code,代码行数:38,代码来源:GYBG_DAO.cs

示例4: encryptBase64Url

 public static string encryptBase64Url(String text)
 {
     text = text.Replace("+","-");
     text = text.Replace("/","_");
     text = text.Replace("=","$");
     return text;
 }
开发者ID:shaahin,项目名称:shTwiX,代码行数:7,代码来源:shFunctions.cs

示例5: publisher_update_task

            public List<String> publisher_update_task( String api, String topic, List<string> pub_uris) 
            {
                XmlRpcValue l = new XmlRpcValue();
                l.Set(0, api);
                l.Set(1, "");
                //XmlRpcValue ll = new XmlRpcValue();
                //l.Set(0, ll);
                for(int i = 0; i < pub_uris.Count; i++)
                {
                    XmlRpcValue ll = new XmlRpcValue(pub_uris[i]);
                    l.Set(i + 1, ll);
                }


                XmlRpcValue args = new XmlRpcValue();
                args.Set(0, "master");
                args.Set(1, topic);
                args.Set(2, l);
                       XmlRpcValue result = new XmlRpcValue(new XmlRpcValue(), new XmlRpcValue(), new XmlRpcValue(new XmlRpcValue())),
                        payload = new XmlRpcValue();

                 Ros_CSharp.master.host = api.Replace("http://","").Replace("/","").Split(':')[0];
                 Ros_CSharp.master.port =  int.Parse( api.Replace("http://", "").Replace("/", "").Split(':')[1]);
                 Ros_CSharp.master.execute("publisherUpdate", args, result, payload, false );
                
                return new List<string>(new []{"http://ERIC:1337"});
            }
开发者ID:uml-robotics,项目名称:ROS.NET,代码行数:27,代码来源:Master_API.cs

示例6: GetLogicalTag

        public static String GetLogicalTag(String templateText)
        {
            String pattern = @"[\[][\%][\?][^[email protected]].*?[\%][\]]";
            Regex regex = new Regex(pattern);
            MatchCollection matchCollection = regex.Matches(templateText);

            bool flags = false;

            pattern = @"(\[\%\?\%\])";
            regex = new Regex(pattern);
            MatchCollection fix = regex.Matches(templateText);
            if (fix.Count != 0)
                flags = true;

            foreach (Match item in matchCollection)
            {
                if (flags)
                {
                    String temp = item.Value.Trim(new Char[] { '[', '%', '?', ']' });

                    templateText = templateText.Replace(item.Value, " if( " + temp + " ) {");

                    templateText = templateText.Replace("[%?%]", " } ");
                }
                else
                {
                    String temp = item.Value.Trim(new Char[] { '[', '%', '?', ']' });

                    templateText = templateText.Replace(item.Value, " if( " + temp + " ) ");
                }
            }

            return templateText;
        }
开发者ID:uHKOrHuTo,项目名称:karabas,代码行数:34,代码来源:ParserSyntaxJava.cs

示例7: ProcessArguments

 /// <summary>
 /// Processes the internal argruments in a string.
 /// </summary>
 public static String ProcessArguments(String data)
 {
     data = data.Replace("$(Quote)", "\"");
     data = data.Replace("$(AppDir)", PathHelper.GetExeDirectory());
     data = Environment.ExpandEnvironmentVariables(data);
     return data;
 }
开发者ID:Gr33z00,项目名称:flashdevelop,代码行数:10,代码来源:ArgProcessor.cs

示例8: modifycatorString

        private String modifycatorString(int inAccuracy, String dataString, int inputStringFormat)
        {
            if (dataString.Length > inAccuracy)
                    dataString = dataString.Substring(0, inAccuracy);

            dataString = dataString.Replace('E', 'e');
            dataString = dataString.Replace('.', ',');

            if (dataString.IndexOf(',') == 0)
            dataString = "0" + dataString;

            if ((dataString[0] != '-') && (dataString[0] != '+'))
                dataString = "+" + dataString;

            if (dataString.IndexOf(',') == -1)
            if (dataString.IndexOf('e') != -1)
                    dataString = dataString.Substring(0, dataString.IndexOf('e')) + ",0" + dataString.Substring(dataString.IndexOf('e'));
            else
                    dataString = dataString + ",0";

            if ((dataString[dataString.IndexOf('e') + 1] != '+')&&
                (dataString[dataString.IndexOf('e') + 1] != '-'))
                dataString = dataString.Replace("e", "e+");

            if (dataString.IndexOf('e') == -1)
                dataString = dataString + "e+0";

            return dataString;
        }
开发者ID:HBArck,项目名称:PostBinary_FormatResearch,代码行数:29,代码来源:Data.cs

示例9: decryptBase64Url

 public static string decryptBase64Url(String base64Url)
 {
     base64Url = base64Url.Replace("-", "+");
     base64Url = base64Url.Replace("_", "/");
     base64Url = base64Url.Replace("$", "=");
     return base64Url;
 }
开发者ID:shaahin,项目名称:shTwiX,代码行数:7,代码来源:shFunctions.cs

示例10: CssRangeToken

 /// <summary>
 /// Creates a new CSS range token.
 /// </summary>
 /// <param name="range">The selected range string.</param>
 /// <param name="position">The token's position.</param>
 public CssRangeToken(String range, TextPosition position)
     : base(CssTokenType.Range, range, position)
 {
     _start = range.Replace(Symbols.QuestionMark, '0');
     _end = range.Replace(Symbols.QuestionMark, 'F');
     _range = GetRange();
 }
开发者ID:Wojdav,项目名称:AngleSharp,代码行数:12,代码来源:CssRangeToken.cs

示例11: JsonObjectToDictionaryList

 public static Dictionary<String, String> JsonObjectToDictionaryList(String StringDataIn)
 {
     Dictionary<String, String> Json = new Dictionary<string, string>();
     StringDataIn = StringDataIn.Replace("{", "");//Beginn of Object
     StringDataIn = StringDataIn.Replace("}", "");//End of Object
     return JsonObjectToDictionary(StringDataIn);
 }
开发者ID:Neuxz,项目名称:RemoteCC_Client,代码行数:7,代码来源:ParseJson.cs

示例12: GetSystemFlags

        public GetSystemFlags(String CurrentFlags)
        {
            InitializeComponent();

            foreach (EnumFlags EFlags in Enum.GetValues(typeof(EnumFlags)))
            {
                _ValueFlags.Add(EFlags.ToString());
            }

            for (int i = 0; i < _ValueFlags.Count; i++)
            {
                listBox_Flags.Items.Add(_ValueFlags[i].ToString());
            }

            // Parse current flags
            CurrentFlags = CurrentFlags.Replace("(", "");
            CurrentFlags = CurrentFlags.Replace(")", "");
            CurrentFlags = CurrentFlags.Replace(" ", "");

            string[] ParsedString = CurrentFlags.Split(new char[]{'+'});
            for (int i = 0; i < ParsedString.Length; i++)
            {
                listBox_Flags.SelectedItems.Add(ParsedString[i]);
            }
        }
开发者ID:Vanganesha,项目名称:oufffteam,代码行数:25,代码来源:GetSystemFlags.xaml.cs

示例13: EscapeForXMLandHTML

 public String EscapeForXMLandHTML(String myString)
 {
     myString = myString.Replace("<", "&lt;");
     myString = myString.Replace(">", "&gt;");
     myString = myString.Replace("&", "&amp;");
     return myString;
 }
开发者ID:loubo,项目名称:sones,代码行数:7,代码来源:HTML_IO.cs

示例14: escapeAscii

 private String escapeAscii(String text)
 {
     text = text.Replace("\x0a", "\\n");
     text = text.Replace("\x0d", "\\r");
     text = text.Replace("\xa0", "\\u00a0");
     return text;
 }
开发者ID:juherr,项目名称:fit,代码行数:7,代码来源:HtmlToTextFixture.cs

示例15: adaptarTexto

        public static String adaptarTexto(String txt)
        {
            if (txt.Substring(0, 2).Equals("rt"))
            {
                txt = txt.Substring(2);
            }

            if (txt != null && !txt.Equals(""))
            {

                char[] acentuados = new char[] { 'ç', 'á', 'à', 'ã', 'â', 'ä', 'é', 'è', 'ê', 'ë', 'í', 'ì', 'î', 'ï', 'ó', 'ò', 'õ', 'ô', 'ö', 'ú', 'ù', 'û', 'ü' };
                char[] naoAcentuados = new char[] { 'c', 'a', 'a', 'a', 'a', 'a', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'u' };

                for (int i = 0; i < acentuados.Length; i++)
                {
                    txt = txt.Replace(acentuados[i], naoAcentuados[i]);
                }

            }

            txt = txt.Replace("rt ", "#rt ");
            txt = txt.Replace("retweet", "#rt");
            txt = txt.Replace("de um #rt", "de #rt");

            txt = removerPontuacao(txt);
            txt = adaptarPreco(txt);

            return txt;
        }
开发者ID:tacsio,项目名称:service-composition,代码行数:29,代码来源:Preprocessador.cs


注:本文中的System.String.Replace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。