1.將www.baidu.com轉(zhuǎn)化成www.udiab.moc
解題思路:1)先將字符串URL用“.”進行分割邪码,產(chǎn)生一個字符串數(shù)組
? ? ? ? ? ? ? ? ? 2)對字符串中的數(shù)組中的每一個數(shù)組元素進行反轉(zhuǎn)
?坑點 :“.”
在正則表達式中嗽上,“.”是具有特殊意義的元字符,能夠匹配除了換行符之外的所有的單個字符,如果使用split(".")將得到含有0個元素的數(shù)組
In regular expression, the "." is a metacharacter with special meaning which matches any single character except a newline. You got an array with zero element because "." mataches any charachers in your string.