LotusScript 一段对字符串前后做修改的程序

出于一个数据库的需要,写了一段程序用来处理不同条件下字符串的组合和修改,使用中觉得还算灵活,当然由此想到一些新的需求可以丰富这个程序功能。如下,有兴趣的可以提建议。灵感来自于正则表达式

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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值