本文整理汇总了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("&", "&");
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();
}
示例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();
}
示例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;
}
示例4: encryptBase64Url
public static string encryptBase64Url(String text)
{
text = text.Replace("+","-");
text = text.Replace("/","_");
text = text.Replace("=","$");
return text;
}
示例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"});
}
示例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;
}
示例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;
}
示例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;
}
示例9: decryptBase64Url
public static string decryptBase64Url(String base64Url)
{
base64Url = base64Url.Replace("-", "+");
base64Url = base64Url.Replace("_", "/");
base64Url = base64Url.Replace("$", "=");
return base64Url;
}
示例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();
}
示例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);
}
示例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]);
}
}
示例13: EscapeForXMLandHTML
public String EscapeForXMLandHTML(String myString)
{
myString = myString.Replace("<", "<");
myString = myString.Replace(">", ">");
myString = myString.Replace("&", "&");
return myString;
}
示例14: escapeAscii
private String escapeAscii(String text)
{
text = text.Replace("\x0a", "\\n");
text = text.Replace("\x0d", "\\r");
text = text.Replace("\xa0", "\\u00a0");
return text;
}
示例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;
}