LotusScript 一段对字符串前后做修改的程序
来源:互联网 发布:退出node命令行 编辑:程序博客网 时间:2024/05/22 06:52
出于一个数据库的需要,写了一段程序用来处理不同条件下字符串的组合和修改,使用中觉得还算灵活,当然由此想到一些新的需求可以丰富这个程序功能。如下,有兴趣的可以提建议。灵感来自于正则表达式
Function specialchar(source As String, symbol As String, action As String, position As String) As String
'============================================================================
' This program is use to convert some special character
' Programmer: Jacky ***
' action: add / remove
' position: left / right
' symbol: the character you want to handle
' Date: 2008-05-09
' How to use it - example
' specialchar("ABCDEFG","ABC","remove","left") = "DEFG"
' specialchar("ABCD","EFG","add","right") = "ABCDEFG"
'============================================================================
Dim x As Integer
Dim y As Integer
specialchar = source
If action = "add" Then
If position = "left" Then
x = Len(symbol)
If Left(source,x) <> symbol Then
specialchar = symbol & source
End If
Elseif position = "right" Then
x = Len(symbol)
y = Len(source)
If Right(source,x)<>symbol Then
specialchar = source & symbol
End If
End If
End If
If action = "remove" Then
If position = "left" Then
x= Len(symbol)
y = Len(source)
If Left(source,x) = symbol Then
specialchar = Right(source,(y-x))
End If
Elseif position = "right" Then
x = Len(symbol)
y = Len(source)
If Right(source,x) = symbol Then
specialchar = Left(source,(y-x))
End If
End If
End If
End Function
Function specialchar(source As String, symbol As String, action As String, position As String) As String
'============================================================================
' This program is use to convert some special character
' Programmer: Jacky ***
' action: add / remove
' position: left / right
' symbol: the character you want to handle
' Date: 2008-05-09
' How to use it - example
' specialchar("ABCDEFG","ABC","remove","left") = "DEFG"
' specialchar("ABCD","EFG","add","right") = "ABCDEFG"
'============================================================================
Dim x As Integer
Dim y As Integer
specialchar = source
If action = "add" Then
If position = "left" Then
x = Len(symbol)
If Left(source,x) <> symbol Then
specialchar = symbol & source
End If
Elseif position = "right" Then
x = Len(symbol)
y = Len(source)
If Right(source,x)<>symbol Then
specialchar = source & symbol
End If
End If
End If
If action = "remove" Then
If position = "left" Then
x= Len(symbol)
y = Len(source)
If Left(source,x) = symbol Then
specialchar = Right(source,(y-x))
End If
Elseif position = "right" Then
x = Len(symbol)
y = Len(source)
If Right(source,x) = symbol Then
specialchar = Left(source,(y-x))
End If
End If
End If
End Function
- LotusScript 一段对字符串前后做修改的程序
- 我自己做的一段程序
- 一段字符串处理程序
- 对pirobox做的修改
- 对一段字符串取反
- 对字符串常量的修改
- 【原创】LS程序 - 字符串的前后增加或减少
- C/C++学习之C提高-----非空格的字符串长度、去掉字符串前后空格、字符串反转、键值对字符串、const练习、二级指针做输入/输出的特性、将字符串按逗号分开,并放入二维数组打印出来
- 分享一段对字符串进行HTML编码解码的代码
- 对jiq中一段程序以及prepare_to_wait的理解
- 一段解析字符串中单词的C语言小程序
- 在LotusScript程序中如何计算程序所用的时间
- LotusScript格式化字符串
- LotusScript解析XML字符串
- 修改字符串中一段的颜色——字符串改变指定位置的颜色
- 一段简单的程序
- 一段有趣的程序
- 自己的一段程序
- 一个美貌女生闯荡北京的真实经历
- C++编程思想学习
- 今天我不卖我的股票20080513
- 地震的背后[转]
- 汶川地震前山东网友发帖称曾看到地震云(图)
- LotusScript 一段对字符串前后做修改的程序
- linux time 函数
- java程序控制台输入数据的一种方法
- DB2相关概念
- db2相关问题解决
- ASP.NET AJAX视频下载
- 有力的出力,有血的出血,有钱的出钱
- IE 和 火狐都支持的日历控件
- COM笔记-组件的创建和类厂