APEXでランダム文字列生成
来源:互联网 发布:2017最流行的网络用语 编辑:程序博客网 时间:2024/05/22 01:05
string getRandomString(Integer LengthRequired){ String CharList = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_'; String Res = ''; integer position; for(Integer i = 0; i <= LengthRequired; i++) { position = Integer.valueof(String.valueof(Math.roundToLong(CharList.length()*Math.random()))) -1; Res += CharList.substring(position,position+1); } return Res; }
追加文字があれば、こんなかんじでしょう。/*** ランダム文字列を生成する* デフォルト:a-zA-Z0-9* @param int(ランダム文字列桁数)、str(追加文字、option)* @return string(ランダム文字列)*/public static String createRandomStr(Integer num, String str) {if(int == null || int < 1) return null;// デフォルト文字列String a = ‘abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890’;// 追加文字列if(str != null && str.length() != 0){String b = str;// 重複判断for(Integer i = 0; i < str.length(); i ++){if(a.contains(str.subString(i,i+1))) b = b.replaceAll(str.subString(i,i+1), ”);}// スペース不要a = (a + b).replaceAll(‘ ‘, ”).replaceAll(‘ ’, ”);}// ランダム文字列を生成するString ranStr = ”;List aList = a.split(”);for(Integer j = 0; j < num; j ++) {ranStr += aList[(Math.random() * a.length()).intValue() + 1];}return ranStr;}
参考
http://arrowhead.blog25.fc2.com/blog-entry-2224.html
http://sfsupport.blog.fc2.com/blog-entry-64.html
0 0
- APEXでランダム文字列生成
- Oracle APEX Report根据列排序
- 【Salesforce】Visualforceの<apex:commandButton>でApexへパラメータを渡す方法
- 【salesforce】カスタムボタンにjavascriptでApexのメソッドを呼ぶ
- 随机生成指定文字的乱数组合的N位文字列
- Oracle APEX 使用htp包动态生成HTML源码
- Oracle APEX 5.0 新手教程(四) 页面动态生成
- 关于文字列处理
- 文字列操作
- Oracle APEX Report的某一个列根据条件显示不同的颜色
- Oracle APEX Classical Report的列根据条件判断显示为Link
- 文字列の比較
- html 竖列显示文字
- html 竖列显示文字
- GridView自动生成列时,利用DIV控制显示长宽 控件数据行和表头文字不换行
- Oracle Apex 实用笔记系列 5 - 在Apex把csv导入数据库Clob字段再导入到各自对应列的解决方法
- 生成变形的文字
- 文字生成图片
- Spring中文件上传,图片上传以及回显
- App应用系统基本信息工具类
- muduo源码分析之实现TCP网络库(连接的接收和关闭)
- Git Stash用法
- 支付宝仍然一意孤行做社交,阿里已别无他路
- APEXでランダム文字列生成
- 用css 添加手状样式,鼠标移上去变小手,变小手
- 2016.11.28回顾
- 导出到EXcel(2)
- 面试(陆续更新)
- 支付宝集成过程
- Invert Binary Tree ---LeetCode
- iOS 开发NSTimer定时器的细节问题
- 414. Third Maximum Number