社区
Java SE
帖子详情
如何判断一个字符串里含有,逗号
javashhai6
2005-12-01 04:00:15
如何判断一个字符串里含有,逗号
...全文
2633
13
打赏
收藏
如何判断一个字符串里含有,逗号
如何判断一个字符串里含有,逗号
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
13 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
crazycy
2005-12-03
打赏
举报
回复
String [] result = test.split( "\\," ) ;
dj0517
2005-12-03
打赏
举报
回复
将程序改了下:
public class GetString {
public static void main(String[] args){
String str = "12hhgdfr3,sasdf456";
int isComma = (str.indexOf(","));
if(isComma == -1)
System.out.println("It doesn't have");
else
System.out.println("It has");
}
}
believefym
2005-12-03
打赏
举报
回复
楼上的错
greenteanet
2005-12-03
打赏
举报
回复
public class GetString {
public static void main(String[] args) {
// TODO Auto-generated method stub
String str = "12hhgdfr3,sasdf456";
int isComma = (str.indexOf(","));
if(isComma > 0)
System.out.println("It has");
else
System.out.println("It doesn't have");
}
}
leekooqi
2005-12-03
打赏
举报
回复
String a = "laskdjfls,;aslkdjflkj";
if(a.indexOf(',') != 0)
System.out.println("It has one ',' index of "+a.indexOf(','));
fog628
2005-12-01
打赏
举报
回复
true表示没有,false表示有逗号
fog628
2005-12-01
打赏
举报
回复
s.matches("^[^,]*$")
PigBrother
2005-12-01
打赏
举报
回复
if(str.indexOf(",") >= 0)
System.out.println("字符串中有逗号");
iwhp
2005-12-01
打赏
举报
回复
检索字符串,发现逗号的话,输出就ok了
rcom10002
2005-12-01
打赏
举报
回复
try {
Pattern regex = Pattern.compile("^[^,]*$",
Pattern.CANON_EQ);
Matcher regexMatcher = regex.matcher(subjectString);
if (regexMatcher.find()) {
// regexMatcher.group(); regexMatcher.start(); regexMatcher.end();
} else {
}
} catch (PatternSyntaxException ex) {
// Syntax error in the regular expression
}
vvpang
2005-12-01
打赏
举报
回复
啊。。。我的方法是错的。。。
我楼上的楼上的,正确的。
yyouyou
2005-12-01
打赏
举报
回复
String类中有方法indexOf();
indexOf
public int indexOf(String str)
返回指定子字符串在该字符串中第一次出现处的索引。
参数:
str - 子字符串。
返回:
若字符串参数作为该对象的子串出现,则返回第一个这样的子串第一个字符的索引,如果它没有作为一个子串出现则返回 -1 。
vvpang
2005-12-01
打赏
举报
回复
String test = "12321,asfd";
String [] result = test.split( "," ) ;
if( result.length > 1 )
{
有逗号
}
Python 47个
字符串
方法
# Python 47个
字符串
方法## 课程介绍同学们是否总是要搜资料、查官网后,才知道怎么操作
字符串
?如果是,来学学本课程吧,本课程以讲解官网文档的方式,讲解 Python 47个
字符串
方法,涉及替换、删除、连接、查找、分割、格式化、编码、转换等
字符串
操作,带同学们系统学习 Python
字符串
方法。
php中的中文
逗号
,php如何
判断
一个
字符串
含有
中文
逗号
?
我用explode分割,发现无法识别中文
逗号
在
字符串
第一位。ps:编码是utf-8.想要的
判断
规则:
字符串
不能
含有
中文
逗号
。例如$str = “,123”; //此处
逗号
为中文
逗号
$str_arr = explode(“,”,$str);最后打印$str_arr,还是得到$str的值,并没有以中文
逗号
分开后来又测试了下,如何中文
逗号
不是第一位,则能分割。这
里
测试是把中文
逗号
放在了第一位。我的测试...
一个
字符串
中包含
逗号
个数
一个
字符串
中包含
逗号
个数 string str = “1,2,3,4,5,6”; 怎么计算此
字符串
中
逗号
的个数? 方法1: string str = “1,2,3,4,5,6”; int count = str.Count(ch => ch == ‘,’); //count=5 方法2: str.Split(’,’).Length-1 方法3: string str = “1,2,3,4,5,6”; int count = str.Length - str.Replace(",", “”).Lengt
在js中,有
一个
字符串
类似:a1,a2,a3,a4 这样,不同
字符串
中使用
逗号
间隔,如何
判断
其中是否包含a3
字符串
?
方法来
判断
一个
字符串
是否包含另
一个
字符串
。具体地,可以先把大
字符串
按照
逗号
进行分割,然后循环遍历分割后的
字符串
数组,对每个小
字符串
使用。执行上述代码,就能输出结果了。其中,如果找到了目标
字符串
,否则,继续循环直到处理完整个
字符串
数组。在 JS 中,可以使用
字符串
的。
java
判断
字符串
是否有
逗号
if(str.indexOf(",")>=0) System.out.println("
字符串
中有
逗号
"); ...
Java SE
62,614
社区成员
307,326
社区内容
发帖
与我相关
我的任务
Java SE
Java 2 Standard Edition
复制链接
扫一扫
分享
社区描述
Java 2 Standard Edition
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章