惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Hackread – Cybersecurity News, Data Breaches, AI and More
宝玉的分享
宝玉的分享
月光博客
月光博客
爱范儿
爱范儿
阮一峰的网络日志
阮一峰的网络日志
酷 壳 – CoolShell
酷 壳 – CoolShell
Recent Announcements
Recent Announcements
A
About on SuperTechFans
T
The Blog of Author Tim Ferriss
博客园 - 叶小钗
U
Unit 42
aimingoo的专栏
aimingoo的专栏
Y
Y Combinator Blog
Martin Fowler
Martin Fowler
N
Netflix TechBlog - Medium
博客园 - 司徒正美
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
云风的 BLOG
云风的 BLOG
M
MIT News - Artificial intelligence
大猫的无限游戏
大猫的无限游戏
J
Java Code Geeks
V
Visual Studio Blog
腾讯CDC
IT之家
IT之家

博客园 - nect

【转】ie9 rc版软件兼容问题 [z]前端设计IE6/IE7/IE8/IE9/FF问题汇总:IE和FirFox兼容问题 - nect - 博客园 [z]ie和FF 在insertRow和insertCell的区别 [z]JS在IE和FF下attachEvent,addEventListener学习笔记 - nect - 博客园 WinForm使用webclient通过http的POST方式上传文件 转:另类解决:“ScriptManager”不是已知元素。原因可能是网站中存在编译错误。 - nect - 博客园 转:css妙用1-用图片替换文字 .net中的正则表达式(一)——转义字符 使用Cascadingdropdown控件遇到的一个问题 IP地址匹配算法 服务器控件的客户端验证脚本 gridview 中模板列无法响应row_command事件 - nect - 博客园 在asp.net Atlas中调用 Web Service时无法找到自定义的Web Service对象的可能原因 【转】Prototype.js开发笔记//mark一下 在GridView中使用邮件链接 【转】ASP.net2。0中解决无法获取 GridView 隐藏列值问题 GridView 中格式化整理 [转]操纵自如--页面内的配合与通信 [导入]Java调用.net的WebService
从一个字符串中Remove另一个字符串
nect · 2007-11-21 · via 博客园 - nect

vb中的string操作方法提供了mid(从string1中截取需要的一段string)的功能,但是实际程序中需要从string1中返回去除string2的字符串,vb代码如下,大家可以模拟改成其他语言。

Public Function RemoveString(SourceString As String, CutString As String, Optional iStart As Long = 1, Optional iSkipCount As Integer = 0As String
    
'删除 SourceString 中的 RemoveString ,从 iStart 开始查找 RemoveString,跳过 iSkipCount 个不删除
    Dim startPos As Long, endPos As Long, iSkip As Integer
    
Dim str1 As String, str2 As String
    
    iSkip 
= iSkipCount
    startPos 
= VBA.InStr(iStart, SourceString, CutString, vbTextCompare)
    
Do While startPos > 0 And iSkip > 0
        startPos 
= VBA.InStr(startPos + 1, SourceString, CutString, vbTextCompare)
        iSkip 
= iSkip - 1
    
Loop
    
If startPos > 0 And iSkip = 0 Then
        str1 
= VBA.Left(SourceString, startPos - 1)
        str2 
= VBA.Right(SourceString, VBA.Len(SourceString) - VBA.Len(str1 + CutString))
        RemoveString 
= str1 + str2
    
Else
        RemoveString 
= SourceString
    
End If

End Function