首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏前端基础

    JavaScript charAt() 方法运用

    一个关于取字符串中的值的方法 charAt 今天偶然同事问了一个问题,如何取到字符串中的每个值,我第一瞬间反应的是,用下标撒,循环打印撒,不就行了,然而并不行,因为是字符串并不是数组,一瞬间就尴尬了,竟然不会做 难点就是在于 如何去循环字符串中的值,其实很简单,就是基础里面的,这里就是w3c中的方法 http://www.w3school.com.cn/jsref/jsref_charAt.asp (js i = 0; i < S.length; i++) { for (let j = 0; j < J.length; j++) { if(J.charAt (j) === S.charAt(i)){ console.log(i); //这里判断等于最好是用恒等于,然后你就可以得到循环判断相等的, console.log(i); 最终的值就是你所拥有的宝石数量了啊

    73640发布于 2019-03-20
  • 来自专栏用户7873631的专栏

    详解length charAt indexOf lastIndexOf includes concat slice substring substr详解

    / 1.获取字符串长度 .length let a="abcd"; //console.log(a.length); // 2.获取某个字符 [索引] / charAt let b="abcd"; let c=b.charAt(1); //console.log(c); // 3.字符串查找 indexOf /

    58420发布于 2020-10-28
  • 来自专栏总栏目

    Contest1620 – 2020-2021-2学期《Java Web 系统开发》:java基础:字符串

    (i)>=65&&str.charAt(i)<=90||str.charAt(i)>=97&&str.charAt(i)<=122)                 str2=str2+str.charAt (i)>=65&&str.charAt(i)<=90||str.charAt(i)>=97&&str.charAt(i)<=122)                 str2=str2+str.charAt str.charAt(i)=='B')                     array[1]++;                 if(str.charAt(i)=='c'||str.charAt str.charAt(i)=='J')                     array[9]++;                 if(str.charAt(i)=='k'||str.charAt |str.charAt(i)=='R')                     array[17]++;                 if(str.charAt(i)=='s'||str.charAt

    43920编辑于 2022-09-05
  • 来自专栏苦逼的码农

    【leetcode】13:罗马数字转整数

    } //4 if (i + 1 < len && s.charAt(i) == 'I' && s.charAt(i + 1) == 'V') { //400 if (i + 1 < len && s.charAt(i) == 'C' && s.charAt(i + 1) == 'D') { //40 if (i + 1 < len && s.charAt(i) == 'X' && s.charAt(i + 1) == 'L') { num += 40 //4 if (i + 1 < len && s.charAt(i) == 'I' && s.charAt(i + 1) == 'V') { num += 4; (s.charAt(i-1)); }else { sum = sum + charToInt(s.charAt(i));

    65320发布于 2019-06-06
  • 来自专栏Java那些事

    【leetcode】13:罗马数字转整数

    } //4 if (i + 1 < len && s.charAt(i) == 'I' && s.charAt(i + 1) == 'V') { //400 if (i + 1 < len && s.charAt(i) == 'C' && s.charAt(i + 1) == 'D') { //40 if (i + 1 < len && s.charAt(i) == 'X' && s.charAt(i + 1) == 'L') { num += 40 //4 if (i + 1 < len && s.charAt(i) == 'I' && s.charAt(i + 1) == 'V') { num += 4; (s.charAt(i-1)); }else { sum = sum + charToInt(s.charAt(i));

    82940发布于 2019-05-14
  • 来自专栏程序员的成长之路

    为什么我们公司强制弃坑FastJson了?主推Jackson~

    (4) == '-' && strVal.charAt(7) == '-' && strVal.charAt(10) == ' ' && strVal.charAt(13) == ':' && strVal.charAt (16) == ':' && strVal.charAt(19) == '.') { int year = num(strVal.charAt(0), strVal.charAt(1), strVal.charAt (strVal.charAt(14), strVal.charAt(15)); int second = num(strVal.charAt(17), strVal.charAt(18)); int nanos = num(strVal.charAt(20), strVal.charAt(21), strVal.charAt(22), strVal.charAt(23), strVal.charAt (24), strVal.charAt(25), strVal.charAt(26), strVal.charAt(27), strVal.charAt(28)); return new Timestamp

    2.8K30发布于 2020-11-06
  • 来自专栏开发者技术前线

    FastJson 又被爆出漏洞,是时候抛弃了

    (4) == '-' && strVal.charAt(7) == '-' && strVal.charAt(10) == ' ' && strVal.charAt(13) == ':' && strVal.charAt (16) == ':' && strVal.charAt(19) == '.') { int year = num(strVal.charAt(0), strVal.charAt(1), strVal.charAt (strVal.charAt(14), strVal.charAt(15)); int second = num(strVal.charAt(17), strVal.charAt(18)); int nanos = num(strVal.charAt(20), strVal.charAt(21), strVal.charAt(22), strVal.charAt(23), strVal.charAt (24), strVal.charAt(25), strVal.charAt(26), strVal.charAt(27), strVal.charAt(28)); return new Timestamp

    1K10发布于 2020-11-24
  • 来自专栏软件工程

    把字符串转换为正数

    (0)=='+'||str.charAt(0)=='-'){//首位判断 sign=str.charAt(0)=='+'? 1:-1; int j=1; while (j<str.length()){ if (str.charAt(j)>48&&str.charAt { return 0; } } }else if (str.charAt(0)>48&&str.charAt (0)<=57){//0的acsii码十进制为48 9为57 res=str.charAt(0)-48; int i=1; while (i<str.length()){ if (str.charAt(i)>48&&str.charAt(i)<=57){ res=res

    63220编辑于 2022-05-13
  • 来自专栏Java旅途

    走你!fastjson!

    (4) == '-' && strVal.charAt(7) == '-' && strVal.charAt(10) == ' ' && strVal.charAt(13) == ':' && strVal.charAt (16) == ':' && strVal.charAt(19) == '.') { int year = num(strVal.charAt(0), strVal.charAt(1), strVal.charAt (strVal.charAt(14), strVal.charAt(15)); int second = num(strVal.charAt(17), strVal.charAt(18)); int nanos = num(strVal.charAt(20), strVal.charAt(21), strVal.charAt(22), strVal.charAt(23), strVal.charAt (24), strVal.charAt(25), strVal.charAt(26), strVal.charAt(27), strVal.charAt(28)); return new Timestamp

    85630发布于 2020-12-18
  • 来自专栏Java学习驿站

    leetcode-28. 实现 strStr()

    = needle.charAt(j)) { j = next[j - 1]; } if (needle.charAt(i) /** 对 haystack 进行遍历,若 haystack.charAt(i) == needle.charAt(j) 一直成立,则不会进入 若 haystack.charAt(i) ! = needle.charAt(j) 时,在 i 不变的的情 况下则要查在 next[] 中上一个 haystack.charAt(i) == needle.charAt(j = needle.charAt(j)) { j = next[j - 1]; } if (haystack.charAt(

    41230编辑于 2022-06-17
  • 来自专栏软件工程

    把字符串转换成整数_49

    for (int i = 0; i < str.toCharArray().length; i++) { if (i==0){ if (str.charAt flag=-1; }else if (str.charAt(i)=='0'&&str.length()==1){ }else if (str.charAt (i)>'0'&&str.charAt(i)<='9'){ num=str.charAt(i)-'0'; } else{ return 0; } }else { if (str.charAt(i)<'0'||str.charAt(i)> '9'){ return 0; }else { num=num*10+(str.charAt

    85420编辑于 2021-12-23
  • 来自专栏技术分享

    反转字符串中的单词

    == s.charAt(fast) && s.charAt(fast) == ' ') 如果最后两个都是空格,那么他只会删除一个,所以有可能会出现多余空格。 (fast-1) == s.charAt(fast) && s.charAt(fast) == ' '){ continue; }else{ str.append(s.charAt(fast)); } } if(str.charAt(str.length()-1) == ' '){ str.deleteCharAt flag || (res.charAt(i)! str.append(s.charAt(fast)); } } if(str.charAt(str.length()-1) == ' '){

    1.4K10编辑于 2024-05-30
  • 来自专栏leetcode_solutions

    【每天一道编程系列-2018.2.22】(Ans)

    (start) == ' ') { while (str.charAt(start) == ' ') { start++; " + str); return 0; } } } if (str.charAt ) == '-') { // 第一个非空白字符中- positive = false; start++; } else if (str.charAt (start) == '+') {// 第一个非空白字符是+ start++; } else if (str.charAt(start) >= '0' && str.charAt (start) >= '0' && str.charAt(start) <= '9') { result = result * 10 + (str.charAt(start) -

    45140发布于 2019-03-14
  • 来自专栏全栈程序员必看

    失去焦点和获得焦点发生事件(js)

    new Array ( ,//, 、, ,, ;, /); i=fibdn.length; j=a.length; for (ii=0;ii { for (jj=0;jj { temp1=a.charAt .时出错 if (num.charAt(i-1)== (j)<0 || num.charAt(j)>9 ) { if (((opt1==0) || (num.charAt(j)! ; return 0; } if ((status==0) && (datestr.charAt(i)! =-)) if ((status==1) && (datestr.charAt(i)!=-)) if ((status==2) && (datestr.charAt(i)!

    10.8K80编辑于 2022-09-07
  • 来自专栏c++ 学习分享

    [JSP] 利用Servlet对用户名和密码进行服务器端验证

    英文逗点 "for(int i=0;i<username.length();i++) { char c = username.charAt for(int j=0;j<password.length()-1;j++) { if(password.charAt for(int k=0;k< password.length()-1;k++) { if((int)password.charAt 英文逗点" for(int i=0;i<username.length();i++) { char c = username.charAt =password.charAt(j+1)) { continue; }

    86210编辑于 2023-07-06
  • 来自专栏*坤的Blog

    leetcode 8 String to Integer

    str.isEmpty()) return 0; int sign = 1, base = 0, i = 0, n = str.length(); while (i < n && str.charAt (i) == ' ') ++i; if (str.charAt(i) == '+' || str.charAt(i) == '-') { sign = (str.charAt 1 : -1; } while (i < n && str.charAt(i) >= '0' && str.charAt(i) <= '9') { if (base > Integer.MAX_VALUE / 10 || (base == Integer.MAX_VALUE / 10 && str.charAt(i) - '0' > 7)) { Integer.MAX_VALUE : Integer.MIN_VALUE; } base = 10 * base + (str.charAt(i++)

    50140发布于 2018-06-04
  • 来自专栏该溜子的专栏

    【算法】字符串算法技巧系列

    字符串相关算法技巧 1:字符串转数组 String a = “abcdefg” char[] a1= a.toCharArray() //将字符串数组转换为字符数组(常用) .charAt 数组转字符串 String.ValueOf(数组名称); 4:字符串拼接方式 方式一: String ret = " "; ret += num[i]; 方式二: 5:返回字符串指定下标的字符 字符串的名字.charAt (i) == ' '){ i--; } while (i >= 0 && s.charAt(i) ! if(num1.charAt(0) == '0' || num2.charAt(0) == '0') return "0"; int n1 = num1.length() , n2 = (i), ch2 = t.charAt(i); if ((map1.containsKey(ch1) && map1.get(ch1) !

    44110编辑于 2025-01-13
  • 来自专栏余生大大

    java根据Stack栈实现公式解析和自定义函数(一)

    (A.charAt(i))) { temp = temp + A.charAt(i); i++; (i) == '(') { bracket.push(A.charAt(i)); } else if(judgeNumber(A.charAt(i (A.charAt(i))) { temp = temp + A.charAt(i); i++; (i) == '+' || A.charAt(i) == '-' || A.charAt(i) == '*' || A.charAt(i) == '/'){ // 先将i (i) == '+' || A.charAt(i) == '-' || A.charAt(i) == '*' || A.charAt(i) == '/'){ // 先将i

    71530编辑于 2022-11-02
  • 来自专栏光城(guangcity)

    数组刷题<下>套路分析

    j-=1; continue; } str[i]=s.charAt(j); str[j]=s.charAt ((s.charAt(i) >= '0' && s.charAt(i) <= '9') || (s.charAt(i) >= 'a' && s.charAt(i) <= 'z'))){ ((s.charAt(j) >= '0' && s.charAt(j) <= '9') || (s.charAt(j) >= 'a' && s.charAt(j) <= 'z'))){ ((s.charAt(i) >= '0' && s.charAt(i) <= '9') || (s.charAt(i) >= 'a' && s.charAt(i) <= 'z') || (s.charAt ((s.charAt(j) >= '0' && s.charAt(j) <= '9') || (s.charAt(j) >= 'a' && s.charAt(j) <= 'z') || (s.charAt

    77720发布于 2019-09-20
  • 来自专栏Java学习网

    如何用Java实现字符串匹配和替换的高效算法?

    int i = 0; i <= n - m; i++) { int j; for (j = 0; j < m; j++) { if (text.charAt = pattern.charAt(j)) { break; } } if (j == m) { return i - j; } else if (i < n && pattern.charAt(j) ! = text.charAt(i)) { if (j ! (i) == pattern.charAt(len)) { len++; lps[i] = len; i++; }

    1.8K10编辑于 2024-05-29
领券