如何使字符串的一些重复部分到LowerCase? [英] how to make some repeating part of the string to LowerCase?
本文介绍了如何使字符串的一些重复部分到LowerCase?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个字符串,
str =http://ask.com/pic.JPG http://ask.com/pic.JPG http://ask.com/pic .jpg;
现在我想把它读作str =http://ask.com/pic.jpg http://ask.com/pic.jpg http://问。 com / pic.jpg
我想把jP的发生从str换成.jpg
怎么办?
解决方案
这是我的解决方案,使其正确;)
var inputString =( http://ask.com/pic.JPG http:/ /aSk.com/pIc.JPG
+ http://ask.com /pic.jpg
+ http://yoursite.com/contact
+ http://yoursite.com/contact?query=value
+ http://yoursite.com/contact?query=value.value
+ http://yoursite.com/contact/
+ http: //yoursite.com/images/Logo.pnG
+ http:// yoursite.com/images/lOgo.pNg?query=value
+ http: //yoursite.com/images/logo.png?query=value.value
+ http://yoursite.com/contact.is.sortof.valid
+ http:// mysite:123 / contact.is.sortof.valid)。分割(' ');
var restultString = 跨度>;
foreach ( var is1 in inputString)
{
restultString + =(!string.IsNullOrEmpty(restultString)? : )+
(Path.HasExtension( is1)?Path.ChangeExtension(is1,Path.GetExtension(is1).ToLower()):is1);
}
试试这个:
string str = http://ask.com/pic.JPG http:// ask .com / pic.JPG http://ask.com/pic.jpg;
string final = str.Replace( JPG, jpg);
尝试:string s = @ http://ask.com/pic.JPG http://ask.com/pic.JPG http://ask.com/pic.jpg。替换( .JPG, 。jpg);
或者:
string s = @ http:// ask .com / pic.JPG http://ask.com/pic.JPG http://ask.com/pic.jpg .ToLower();
I have a string,
str="http://ask.com/pic.JPG http://ask.com/pic.JPG http://ask.com/pic.jpg";
Now I want to read it as str="http://ask.com/pic.jpg http://ask.com/pic.jpg http://ask.com/pic.jpg"
I jus want to replace the occurrence of .JPG from str to .jpg
how to do it?
解决方案
here is my solution to make it right ;)
var inputString = ("http://ask.com/pic.JPG http://aSk.com/pIc.JPG " + "http://ask.com/pic.jpg " + "http://yoursite.com/contact " + "http://yoursite.com/contact?query=value " + "http://yoursite.com/contact?query=value.value " + "http://yoursite.com/contact/ " + "http://yoursite.com/images/Logo.pnG " + "http://yoursite.com/images/lOgo.pNg?query=value " + "http://yoursite.com/images/logo.png?query=value.value " + "http://yoursite.com/contact.is.sortof.valid " + "http://mysite:123/contact.is.sortof.valid").Split(' '); var restultString = ""; foreach (var is1 in inputString) { restultString += (!string.IsNullOrEmpty(restultString) ? " " : "") + (Path.HasExtension(is1) ? Path.ChangeExtension(is1, Path.GetExtension(is1).ToLower()) : is1); }
Try this:
string str= "http://ask.com/pic.JPG http://ask.com/pic.JPG http://ask.com/pic.jpg"; string final = str.Replace("JPG","jpg");
Try:string s = @"http://ask.com/pic.JPG http://ask.com/pic.JPG http://ask.com/pic.jpg".Replace(".JPG", ".jpg");
Alternatively:
string s = @"http://ask.com/pic.JPG http://ask.com/pic.JPG http://ask.com/pic.jpg".ToLower();
这篇关于如何使字符串的一些重复部分到LowerCase?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文