2008年07月24日 星期四 [集日] [旧版首页]
我不介意你恨我啵一个一首歌真爱地图相反词来跳舞吧
爱在现实面前雨霖铃树叶的崇拜日不落完美故事冰冰
快乐童话嘟嘟娃娃路太弯差一点让我看着你客串情人
当前位置:首页 >> VFP专区 >> 字符串常用函数
在线连续剧免费播放:     五星大饭店     奋斗     血色浪漫     家有儿女     荣归     大明天子     连城诀    

字符串常用函数

作者:  发布时间:2005-03-18 >>  -收藏本页-

*!* 函数说明
*!* toLeftStr(tcSearched, tcSearchFor)toLeftStr(tcSearched, tcSearchFor) 获取字符串tcSearched的前面部分,以tcSearchFor分割!tcSearchFor。
*!* toRightStr(tcSearched, tcSearchFor) 获取字符串tcSearched的后面部分,以tcSearchFor分割!不包含tcSearchFor。
*!* toLimitStr(tcSearched, tLimit, tnCount) 获取tcSearched串中以tcLimit为分隔符分割后第tnCount段的数据。
*!* toTrimStr(tcText, tlSpace) 删除前后空格和空行
*!* toMidStr(tcSearched, tcBegin, tcEnd) 根据tcSearched返回tcBegin和tcEnd之间的字符串,如果没有匹配的内容,返回空!

****************************************
* 功能说明:
*  根据tcSearched返回tcBegin和tcEnd之间的字符串,如果没有匹配的内容,返回空!
*
* 参数说明:
*  tcSearched 查找字符串
*  tcBegin 开始字符串
*  tcEnd 结束字符串
*
* 返回说明: 字符串内容                                                               
*
* 日    期: 2001.08.27
* 作    者: 天涯闲人
*
* 修改记录:
****************************************
FUNCTION toMidStr
 Lparameters tcText, tcBegin, tcEnd
 Local lcHead, lcReturn
 lcHead = toLeftStr(tcText, tcEnd)
 if Empty(lcHead)
  return ''
 endif
 lcReturn = toRightStr(lcHead, tcBegin)
 return lcReturn
ENDFUNC

****************************************
* 功能说明:
*  获取tcSearched串中以tcLimit为分隔符分割后第tnCount段的数据。
*
* 参数说明:
*  tcSearched 查找的字符串
*  tcLimit 分隔字符串
*  tcTime 第几次内容
*
* 返回说明: 字符串内容                                                               
*
* 日    期: 2001.08.27
* 作    者: 天涯闲人
*
* 修改记录:
****************************************
FUNCTION toLimitStr
LPARAMETERS tcString, tcLimit, tnTime

PRIVATE ALL LIKE l*
lcReturn = ''

lcString = tcString + tcLimit
IF tnTime = 1
 lnAt = AT(tcLimit, lcString, tnTime)
 lcReturn = SUBSTR(lcString, 1, lnAt - 1)
 RETURN lcReturn
ENDIF

lnAt = AT(tcLimit, lcString, tnTime)
IF lnAt <= 0
 RETURN lcReturn &&返回空串
ENDIF

lnAt_1 = AT(tcLimit, lcString, tnTime - 1)
lcReturn = SUBSTR(lcString, lnAt_1 + LEN(tcLimit), lnAt - lnAt_1 - LEN(tcLimit))
RETURN lcReturn
ENDFUNC

****************************************
* 功能说明:
*  删除前后空格和空行
*
* 参数说明:
*  tcText  需要处理的字符串
*
* 返回说明: 删除空格和空行
*
* 日    期: 2001.08.27
* 作    者: 天涯闲人
*
* 修改记录:
****************************************
FUNCTION toTrimStr
LPARAMETERS tcText, tlSpace
Local lcRet, lcReturn, lcText, lnFind, lcLine

lcText = tcText
lcRet = CHR(13) + CHR(10)
lcReturn = ''

if ((chr(13)$lcText) and !(chr(10)$lcText))
 lcText = strtran(lcText, chr(13), chr(13) + chr(10))
endif

lcText = strtran(lcText, chr(9), space(4))
lnFind = AT(lcRet , lcText, 1)

DO WHILE lnFind > 0
 lcLine = toLeftStr(lcText, lcRet)
 if tlSpace
  lcLine = alltrim(lcLine)
 endif
 if !Empty(lcLine)
  lcReturn = lcReturn + lcLine + lcRet
 endif
 lcText = toRightStr(lcText, lcRet)
 lnFind = AT(lcRet , lcText, 1)
ENDDO

lcReturn = lcReturn + lcText
RETURN lcReturn
ENDFUNC

****************************************
* 功能说明:
*  获取字符串tcSearched的前面部分,以tcSearchFor分割!tcSearchFor。
*
* 参数说明:
*  tcSearched 被查找的字符串
*  tcSearchFor 查找的字符串
*
* 返回说明: 前面部分内容                                                             
*
* 日    期: 2001.08.27
* 作    者: 天涯闲人
*
* 修改记录:
****************************************
function toLeftStr
lparameters tcSearched, tcSearchFor

Local lcReturn, lnAt

if len(tcSearchFor) = 0
 return ''
endif

lnAt = AT(tcSearchFor, tcSearched, 1)
if lnAt <= 1 &&没有匹配
 return ''
endif

lcReturn = left(tcSearched, lnAt - 1)
return lcReturn
endfunc

****************************************
* 功能说明:
*  获取字符串tcSearched的后面部分,以tcSearchFor分割!不包含tcSearchFor。
*
* 参数说明:
*  tcSearched 字符串内容
*  tcSearchFor 查找串内容
*
* 返回说明: 字符串                                                                   
*
* 日    期: 2001.08.27
* 作    者: 天涯闲人
*
* 修改记录:
****************************************
function toRightStr
lparameters tcText, lcFind
Local lcReturn , lnAt

if len(lcFind) = 0
 return ''
endif

lnAt = AT(lcFind, tcText, 1)
if lnAt <= 0 &&没有匹配
 return ''
endif

lcReturn = right(tcText, len(tcText) - lnAt - len(lcFind) + 1)
return lcReturn
endfunc

·本文总评分:0 分 给此网页评分:
·推荐给好友或网友
网址: UBB代码:
我也说两句……  
用户名: 密码: 匿名发表 登陆 注册
图 像:
·请您对您的言行负责,遵守中华人民共和国有关法律、法规,尊重网上道德;
·承担一切因您的行为而直接或间接导致的民事或刑事法律责任;
·留言板管理人员有权保留或删除其管辖留言中的任意内容。
标题
关键字:音乐欣赏 益智游戏 开口一笑 网站建设 JAVASCRIPT VFP开发 常用下载 哲理小故事
除特别说明,本站点所有内容和作品都按照创作共用方式授权
本站点及发布平台统一使用 eaccelerator 优化,特此感谢。
联系站长 天外闲人 版权所有 琼ICP备05003420号 QQ群:39137597
[访问计数: 1601054]
alexa排名 | 191235