java 字符串 大小写转换 、去掉首末端空格 、根据索引切割字符 、判断是否含有某连续字符串
1.
字符串转大写: toUpperCase() 字符串转小写: toLowerCase()
@Test
public void tt(){
String d = "sdgGHJGjghGHJGHG";
System.out.println(d);
System.out.println(d.toUpperCase());
System.out.println(d.toLowerCase()); }
打印

2.
去掉首末端空格: trim()
@Test
public void tt(){
String d = "sdgGHJGjghGHJGHG ";
System.out.println(d+"ff");
System.out.println(d.trim()+"ff");
}
打印

3.
根据索引切割字符: substring()
注意substring 切割的是包含首字符,不包含尾字符,即 [ , )
如果只有一个参数,如
String s = "12345";
System.out.println(s.substring(2));
打印为345
也就是说s.substring(2)相当于s.substring(2,s.length())
截取后面所有
@Test
public void tt(){
String d = "1+1=2";
System.out.println("字符串长度,即字符个数:"+d.length());
//注意substring 切割的是包含首字符,不包含尾字符,即 [ , )
System.out.println(d.substring(1,3));
}
打印

4.
判断是否含有某连续字符串 :contains()
@Test
public void tt(){
String d = "1+1=2";
System.out.println(d.contains("1="));
System.out.println(d.contains("2="));
}
打印

java 字符串 大小写转换 、去掉首末端空格 、根据索引切割字符 、判断是否含有某连续字符串的更多相关文章
- java字符串大小写转换的两种方法
转载自:飞扬青春sina blogjava字符串大小写转换的两种方法 import java.io..* public class convertToPrintString { pu ...
- 【转】Python 字符串大小写转换
转载自:python 中字符串大小写转换 一.pyhton字符串的大小写转换, 常用的有以下几种方法: 1.对字符串中所有字符(仅对字母有效)的大小写转换,有两个方法: print 'just to ...
- [Swift]字符串大小写转换,同时实现本地化或设置语言环境
在NSString中提供了3种字符串大小写转换方式:1. 转换字符串大小写2. 转换字符串大小写,并实现本地化3. 转换字符串大小写,并设置语言环境. 一. 转换字符串大小写如果只是想单纯的将字符串进 ...
- linux bash shell:最方便的字符串大小写转换(lowercase/uppercase conversion) (转)
原文地址:https://blog.csdn.net/10km/article/details/83384145 关于字符串大小写转换,是写 linux 脚本经常干的事儿,所以总想找个方便的方法让我少 ...
- python 字符串大小写转换(不能使用swapcase()方法)
python 3字符串大小写转换 要求不能使用swapcase()方法 #!/usr/bin/env python # -*- coding:utf-8 -*- # Author:Hiuhung Wa ...
- boost 字符串大小写转换
示例代码如下: #include <boost/algorithm/algorithm.hpp> #include <iostream> using namespace std ...
- std::string 字符串大小写转换(转)
该问题归结为std::transform函数的使用 函数原型 template < class InputIterator, class OutputIterator, class UnaryO ...
- php字符串大小写转换
strtoupper().strtolower().ucfirst().ucfirst().ucwords().mb_strtoupper().mb_strtolower()和mb_convert_c ...
- java字符串大小写转换
String test="SHA34cccddee"; System.out.println(test.toUpperCase());//小写转大写 String test= ...
随机推荐
- 因Console.Read()导致Centos 后台运行.net core程序报错
.net 控制台程序通常用 Console.Read(),或者Console.ReadKey()让进程阻塞保持,不退出. 但在.net core 需要将程序放在后台执行时 用Console.Read( ...
- JS 中常用的去重
第一种:indexOf (获取字符串值在字符串中首次出现的位置,若没有这个值,则返回-1) let arr = [15,45,88,45,78,15,55,88]; let arr1 = []; // ...
- ERROR: Command errored out with exit status 1:安装pip3 install --user pyecharts==0.5.11失败问题总结
一.前言:最近在学习pyecharts学习到Grid时候发现代码无法运行了,经过在网上查找资料说是pyecharts版本不适配了,之前的版本是 pip install pyecharts==0.1.9 ...
- InnoDB学习(五)之MVCC多版本并发控制
MVCC多版本并发控制,是一种数据库管理系统并发控制的方法.MVCC多版本并发控制下,数据库中的数据会有多个版本,分别对应不同的事务,从而达到事务之间并发数据的隔离.MVCC最大的优势是读不加锁,读写 ...
- Python中冷门但非常好用的内置函数
Python中有许多内置函数,不像print.len那么广为人知,但它们的功能却异常强大,用好了可以大大提高代码效率,同时提升代码的简洁度,增强可阅读性 Counter collections在pyt ...
- 果蝇优化算法_Fruit Fly Optimization
1. 果蝇优化算法背景 在夏天,果蝇是一种随处可见的昆虫.果蝇在嗅觉和视觉特别突出.腐烂的食物发出一种刺鼻的味道,温度越高这种气味的扩散速度较快,果蝇对这种味道非常敏感.腐烂的味道和食物的位置有关.一 ...
- Cyber Apocalypse 2021 pwn write up
Controller 考点是整数溢出和scanf函数的引发的栈溢出漏洞,泄露libc地址将返回地址覆盖成one_gadgets拿到shell. 1 from pwn import * 2 3 p = ...
- MVC中的打印功能
HTML页面: @{ Layout = "~/Views/Shared/_IframeLayout.cshtml";}@Scripts.Render(ViewBag.ScriptP ...
- 使用iframe内嵌PC网站实现高度自适应
加个样式 <style> iframe { display: block; border: none; height: 90vh;/*设置高度百分比,一直调到只有一个滚动调为止*/ wid ...
- c++之sigslot库
关于 本文演示环境: win10 + VS2017 1. demo #include <iostream> #include "sigslot.h" using nam ...