Flex StringUtil工具类
最近发现Flex处理字符串的工具类一共有三个,分别是:
- mx.utils包下的StringUtil
- mx.utils包下的RPCStringUtil
- as3corelib类库下的StringUtil
下面分别整理及介绍下这三个工具类的用法:
mx.utils包下的StringUtil
1.trim()
2.isWhitespace() 判断是否是空白字符
3.trimArrayElements()
删除数组中每个元素的开头和末尾的所有空格字符,此处数组作为字符串存储。
4.substitute()
使用传入的各个参数替换指定的字符串内的“{n}”标记。
示例:
var str:String = "here is some info '{0}' and {1}"; trace(StringUtil.substitute(str, 15.4, true)); // this will output the following string: // "here is some info '15.4' and true"
mx.utils包下的RPCStringUtil
mx.utils下包StringUtil的子集,用法同StringUtil
as3corelib类库下的StringUtil
- stringsAreEqual() 判断字符串是否相等
- trim() 去除首尾的空白字符
- ltrim() 去除首部的空白字符
- rtrim() 去除尾部的空白字符
- beginsWith() 判断字符串是否已该前缀开头
- endsWith() 判断字符串是否已该后缀结尾
- remove() 去除字符串中的部分字符
- replace() 替换字符串中的部分字符
- stringHasValue() 判断字符串是否有值
代码示例:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" backgroundColor="#ffffff"layout="absolute"><mx:Script><![CDATA[import com.adobe.utils.StringUtil;]]></mx:Script><mx:VBox><mx:HBox><mx:Label text="input1"/> <mx:TextInput id="input1" text="input1"/></mx:HBox><mx:HRule width="100%" height="1"/> <mx:HBox><mx:Label text="is input1 begins with:"/> <mx:TextInput id="beginsWith" text="i"/></mx:HBox> <mx:HRule width="100%" height="1"/> <mx:Text text="beginsWith:{ StringUtil.beginsWith(input1.text,beginsWith.text)}"/><mx:HRule width="100%" height="1"/><mx:Text text="input1 has value ?:{ StringUtil.stringHasValue(input1.text) }"/><mx:HRule width="100%" height="1"/><mx:HBox><mx:Label text="is input1 ends with:"/> <mx:TextInput id="endsWith" text="1"/></mx:HBox><mx:Text text="endsWith:{ StringUtil.endsWith(input1.text,endsWith.text)}"/> <mx:HRule width="100%" height="1"/><mx:HBox><mx:Label text="string to be removed from input1"/> <mx:TextInput id="removeString"/></mx:HBox><mx:Text text="remove:{ StringUtil.remove(input1.text,removeString.text)}"/><mx:HRule width="100%" height="1"/><mx:HBox><mx:Label text="string to be replaced from input1"/> <mx:TextInput id="replace"/></mx:HBox><mx:HBox><mx:Label text="string to be replace with"/> <mx:TextInput id="replaceWith"/></mx:HBox> <mx:Text text="replace:{ StringUtil.replace(input1.text,replace.text,replaceWith.text) }"/><mx:HRule width="100%" height="1"/><mx:Text text="ltrim:{ StringUtil.ltrim(input1.text)}"/><mx:Text text="trim:{StringUtil.trim(input1.text)}"/><mx:Text text="rtrim:{StringUtil.rtrim(input1.text)}"/><mx:HRule width="100%" height="1"/><mx:HBox><mx:Label text="input2"/> <mx:TextInput id="input2" text="input1"/><mx:Label text="is case sensitive?"/><mx:CheckBox id="caseSensitive" selected="true"/></mx:HBox><mx:Text text="input1 and input2 are equal?:{ StringUtil.stringsAreEqual(input1.text,input2.text,caseSensitive.selected)}"/></mx:VBox>
</mx:Application>
输出结果:
Flex StringUtil工具类相关推荐
- StringUtil工具类
1.字符串达到多长才截取 2.将指定的对象转换为String类型 3.转换字符,用于替换提交的数据中存在非法数据:"'" 4.对标题""转换为中文"& ...
- StringUtil工具类详解
org.apache.commons.lang.StringUtils中方法的操作对象是java.lang.String类型的对象,是JDK提供的String类型操作方法的补充,并且是null安全的( ...
- java操作字符串的工具类StringUtil
依赖引入 <dependency><groupId>commons-lang</groupId><artifactId>commons-lang< ...
- Bootstrap(一)——简介、布局容器和工具类使用(flex布局)
文章目录 一.Bootstrap简介 二.布局容器 2.1 定宽容器 container 2.2 变宽容器 container-fluid 三.工具类 3.1 颜色与排版 (1)常用颜色 (2)常用排 ...
- java StringUtil之String工具类
StringUtil之String工具类 获取字典字符串中的value <功能详细描述> public static final String dictToValue(String mSt ...
- StringUtil:字符串处理的工具类
一个字符串处理的工具类(●'◡'●) 包含以下功能: 判断应用程序是否安装 字符拆分成数组 MD5 加密 拼接后的字符串 替换字符串 判断多个参数是否都为空 将字符串转换成HTML格式的字符串 将HT ...
- 可执行SQL文的mybatis工具类
1.创建工具类 import org.apache.ibatis.builder.StaticSqlSource; import org.apache.ibatis.exceptions.TooMa ...
- 字符串工具类、数组工具类、集合工具类、转型操作工具类、编码与解码操作工具类...
package hjp.smart4j.framework.util;import org.apache.commons.lang3.StringUtils;/*** 字符串工具类*/ public ...
- 一个基于POI的通用excel导入导出工具类的简单实现及使用方法
前言: 最近PM来了一个需求,简单来说就是在录入数据时一条一条插入到系统显得非常麻烦,让我实现一个直接通过excel导入的方法一次性录入所有数据.网上关于excel导入导出的例子很多,但大多相互借鉴. ...
- 实现-驼峰和下划线的转换 工具类
/*** 工具类-驼峰和下划线的转换*/ public class StringUtil {/*** 下划线命名转驼峰命名* @param underscore* @return*/public st ...
最新文章
- cisco 访问控制列表ACL笔记
- android systemtrace 报错
- python如何编程-怎么用手机编写Python程序?
- 用番茄工作法提升工作效率 (三)工作任务的管理(系列完结篇)
- BGP信息类型和分组公共首部
- 斯坦福大学机器学习第六课“逻辑回归(Logistic Regression)”
- 链表反转leetcode206
- 2019牛客暑期多校训练营(第九场)-E All men are brothers
- position: absolute;_前端性能优化--transform与position
- LoadRunner实战
- 近6年语音合成领域都有哪些论文?
- 通示jQuery实例方法,未DOM对象添加多个方法
- java docx 内存溢出_第2章 Java内存区域与内存溢出异常
- 基于JAVA+SpringBoot+Mybatis+Vue+MYSQL的智慧养老管理系统
- 现代质量管理方法的应用思考和实践
- 学习 shell —— 相对路径转换为绝对路径
- 送你一份万字机器学习资料
- 软件设计师(中级)历年真题与知识点总结(更新中...)
- 2020FME博客大赛——FME在农村地籍调查项目中应用
- 2022年下半年软考报名时间汇总,最新版!