Replace ignoring case
-
2012年8月2日 17:26
Hi,
How can I replace a string ignoring it's case to another ?
For example: I need that
ACEFii, ACEFII, acefii, ACEfii and all others variations to be replace by ACEFII (to avoid user mistyping..)
http://BrunoZP.com.br || http://BrunoZP.com
全部回复
-
2012年8月2日 17:31
I think the StringComparison.CurrentCultureIgnoreCase could solve your problem.Web Developer
- 已标记为答案 BrunoZP 2012年8月3日 12:23
-
2012年8月2日 17:46
Or Alternatively use Regex.Replace and use (?i) which will ignore case. Or use the IgnoreCase option.- 已标记为答案 BrunoZP 2012年8月3日 12:23
-
2012年8月2日 18:33
You can use String.ToUpper Method ().
Currently developing FaultTrack. I occassionally blog about C# and .NET.
Hoping to become a MVP by 2013. Email: danderson [at] dcomproductions [dot] com -
2012年8月2日 18:36
ToUpper doesnt ignore case.You can use String.ToUpper Method ().
Currently developing FaultTrack. I occassionally blog about C# and .NET.
Hoping to become a MVP by 2013. Email: danderson [at] dcomproductions [dot] comWeb Developer
-
2012年8月2日 18:41
string val = "AStringValue"; if (val.Equals("astringvalue", StringComparison.InvariantCultureIgnoreCase)) { }This example ignores case.
Web Developer
- 已编辑 NorkkMicrosoft Community Contributor 2012年8月2日 18:41
- 已建议为答案 Akayster 2012年8月2日 18:50
- 已标记为答案 Jason Dot WangMicrosoft Contingent Staff, Moderator 2012年8月10日 8:20
-
2012年8月2日 18:47
Also,
String val = "AStringValue"; if (Regex.IsMatch(val, "astringvalue", RegexOptions.IgnoreCase)) { }
- 已建议为答案 Akayster 2012年8月2日 18:50
- 已标记为答案 Jason Dot WangMicrosoft Contingent Staff, Moderator 2012年8月10日 8:20
-
2012年8月2日 19:29Do you need to look "acefii" or similar in sentence or from text or just single word?
-
2012年8月2日 20:20
You can use String.ToUpper Method ().
Currently developing FaultTrack. I occassionally blog about C# and .NET.
ToUpper doesnt ignore case.
Hoping to become a MVP by 2013. Email: danderson [at] dcomproductions [dot] com
Web Developer
If you look close at his post, the strings are all the same except for case, and from what I gathered he just wants it to end up as upper casing. You don't need to replace characters to do that.Currently developing FaultTrack. I occassionally blog about C# and .NET.
Hoping to become a MVP by 2013. Email: danderson [at] dcomproductions [dot] com

