在SHELL编程中,经常要处理一些字符串变量。比如,计算长度啊、截取子串啊、字符替换啊等等,常常要用到awk、expr、sed、tr等命令。下面给大家介绍个简单的字符串处理方法,用不着嵌套复杂的子命令。
${#VALUE}:计算VALUE字符串的字符数量。
${VALUE%.*}或${VALUE%%.*}:删除VALUE字符串中以分隔符“.”匹配的左边字符,保留右边字符。
${VAL...
分类:
其他好文 时间:
2014-08-13 13:04:46
阅读次数:
216
#includeconst int maxn=100 +10;int val[maxn],vtop;int op[maxn],otop;void insert(int b){ while(otop &&op[otop-1]==3) { b=!b; --otop; } val[vtop++]=b;.....
分类:
其他好文 时间:
2014-08-13 12:59:36
阅读次数:
243
jQuery获取文件选择输入框的扩展名var file=$("input[name='file']").val()var filename=file.replace(/.*(\/|\\)/, ""); //文件名var fileExt=(/[.]/.exec(filename)) ? /[^.]+....
分类:
Web程序 时间:
2014-08-13 12:58:36
阅读次数:
276
题目字典树,注意初始化的位置~!!位置放错,永远也到不了终点了org。。。。我是用数组模拟的字典树,这就要注意内存开多少了,,要开的不大不小刚刚好真的不容易啊。。。。我用了val来标记是否是同一个串分解而来的,保存的是串的编号num记录数目。//string &replace(iterator fi...
分类:
其他好文 时间:
2014-08-13 12:15:06
阅读次数:
266
一. 二叉树定义:二叉树具有天然的递归特性,凡是二叉树相关题,首先应该联想到递归struct BinTreeNode { BinTreeNode* left; BinTreeNode* right; int val; BinTreeNode(int valu...
分类:
其他好文 时间:
2014-08-12 21:45:24
阅读次数:
314
模拟大法保平安_(:зゝ∠)_
#include
#include
#include
#include
using namespace std;
const int N = 1;
struct node{
int x, y, val;
node(int a=0,int b=0,int c=0):x(a),y(b),val(c){}
bool operator<(...
分类:
其他好文 时间:
2014-08-12 19:07:44
阅读次数:
224
#!/bin/bash
#unzip?zip&tar?file
function??untarfile(){
for?i?in?$(?ls?.?|grep?-v?.sh)
do
val=$(echo?$i?|?grep?".zip$"?|wc?-l)
if?[[?"$val"??-eq??1?]];then
dirname=$(echo?...
分类:
其他好文 时间:
2014-08-12 17:47:04
阅读次数:
237
这个程序看到几点: 1 TypeOf和ValueOf是获取Type和Value的方法 2 ValueOf返回的<float64 Value>是为了说明这里的value是float64 3 第三个b的定义实现了php中的string->method的方法,为什么返回的是reflect.Val...
分类:
其他好文 时间:
2014-08-12 14:01:44
阅读次数:
234
1:jQuery.fn.extend(object); 给jQuery对象添加方法。js封装文件示例$.fn.extend({ alertWhileClick:function(){ $(this).click(function(){ alert($(this).val()); }); }...
分类:
Web程序 时间:
2014-08-12 13:20:24
阅读次数:
261
1、 格式化字符串
1 java.text.DecimalFormat df = new java.text.DecimalFormat("#0.00");
2 float val=Float.valueOf(df.format(6.6666666666));
2、BigDe...
分类:
编程语言 时间:
2014-08-12 12:48:04
阅读次数:
240