紧急,怎样在数字前面加下划线呢

supergirlbarbie 2012-06-07 01:03:22
class StrPart{
public static void main(String args[]){
String s="student teacher I Beijing123 shanghai nanjing You.";
String text="",word=null;
int i=0,start,end;
char ch;
start=0;
end=s.length();

s.trim();
while(start<end)
{ s=s.trim();
for(i=0;i<s.length();i++){
ch=s.charAt(i);
if(ch==' ')
break;

}
end=i;
word=s.substring(start,end);
//首字母变大写
/*String temp="";
int k;
for(k=0;k<word.length();k++)
{
ch=word.charAt(k);
if(ch>='a'&& ch<='z'&&k==0)
ch=(char)(ch-32);
temp+=ch;
}
//数字前插入下划线
???
text+=word+" ";
s=s.substring(end,s.length());
start=0;
end=s.length();
}
System.out.println(text);
}
}
...全文
89 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
supergirlbarbie 2012-06-07
  • 打赏
  • 举报
回复
我刚入门,还不懂正则是什么
hybeureka 2012-06-07
  • 打赏
  • 举报
回复
估计得用正则...

23,404

社区成员

发帖
与我相关
我的任务
社区描述
Java 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧