import java.util.regex.Matcher; import java.util.regex.Pattern; public class Demo { //判断"Ab2Ad3A4"中"A"出现第二次的位置 public static void main(String[] args) { String str = "Ab2Ad3A4"; Pattern pattern = Pattern.compile("A")…
ASCII(American Standard Code for Information Interchange,美国信息交换标准代码)是基于拉丁字母的一套电脑编码系统,主要用于显示现代英语和其他西欧语言. 它是现今最通用的单字节编码系统,并等同于国际标准ISO/IEC 646. 请注意,ASCII是American Standard Code for Information Interchange缩写,而不是ASCⅡ(罗马数字2),有很多人在这个地方产生误解. 在Swift中实现:字符串根据索…
/*这是第100000份数据,要截取出100000*/ String s="这是第100000份数据"; String s1 = s.substring(s.indexOf("第") + 1, s.indexOf("份")); /*判断指定字符出现了几次*/ public static int countStr(String str, char key) { int count = 0; for (int i = 0; i < str.le…
    最近有个需求需要获取一个指定包下的所有类的全类名,因此特意写了个获取指定包下所有类的全类名的工具类.在此记录一下,方便后续查阅 一.思路         通过ClassLoader来查找指定包,如果是在classes文件夹下的class文件,则用遍历文件的方式来获取该包下的所有类名.如果这个包名是jar包里面的,那么需要通过遍历jar包内文件的方式来获取该包下的所有类的类名 二.代码        代码如下 package com.zxy.demo.common.utils; impor…
获取指定长度随机数,含大小写字母和数字 package org.sw; import java.util.Random; /** * 得到指定位数的随机数 * @author mengzw * @since 3.0 2014-2-28 */ public class DemoRandom { /** * 获取随机数 * @param length * @return */ public String getCharAndNumr(int length) { String val = ""…
有以下两种方法获取指定时间的毫秒值: 1.Calendar类 先由getInstance获取Calendar对象,然后用clear方法将时间重置为(1970.1.1 00:00:00),接下来用set方法设定指定时间,最后用getTimeMillis获取毫秒值. Calendar calendar = Calendar.getInstance(); calendar.clear(); calendar.set(2018,0,1); long millis = calendar.getTimeIn…
Java 手册 concat public String concat(String str) 将指定字符串连接到此字符串的结尾. 如果参数字符串的长度为 0,则返回此 String 对象.否则,创建一个新的 String 对象,用来表示由此 String 对象表示的字符序列和参数字符串表示的字符序列连接而成的字符序列. 示例: "cares".concat("s") returns "caress" "to".concat(…
<!doctype html> <html> <head> <meta charset="utf-8"> <title>无标题文档</title> </head> <script type="text/javascript"> /* string 字符串; str 指定字符; split(),用于把一个字符串分割成字符串数组; split(str)[0],读取数组中索引为…
要求:获取某个字符指定字符的前面或后面的所有字符内容 示例: URL = https://www.baid/v2/user/login (1)想要获取v2的数据:v2/user/login print  url[url.rfind('/v2'):] (2)想要获取/v2前的数据:https://www.baid/ print  url[0:url.rfind('/v2')]…
例如获取2020年5月一共有多少个星期二,一共跨了多少个星期 public class MainTest { public static void main(String[] args) throws ParseException { SimpleDateFormat sp = new SimpleDateFormat("yyyyMM"); SimpleDateFormat sp2 = new SimpleDateFormat("yyyy年MM月"); String…