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

推荐订阅源

宝玉的分享
宝玉的分享
酷 壳 – CoolShell
酷 壳 – CoolShell
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
S
Security @ Cisco Blogs
小众软件
小众软件
D
Docker
博客园_首页
A
About on SuperTechFans
P
Privacy International News Feed
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
A
Arctic Wolf
Spread Privacy
Spread Privacy
有赞技术团队
有赞技术团队
T
Tailwind CSS Blog
Latest news
Latest news
WordPress大学
WordPress大学
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
T
The Exploit Database - CXSecurity.com
C
Cybersecurity and Infrastructure Security Agency CISA
大猫的无限游戏
大猫的无限游戏
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
K
Kaspersky official blog
V2EX - 技术
V2EX - 技术
SecWiki News
SecWiki News
U
Unit 42
GbyAI
GbyAI
H
Hackread – Cybersecurity News, Data Breaches, AI and More
L
LINUX DO - 热门话题
S
Security Affairs
Y
Y Combinator Blog
aimingoo的专栏
aimingoo的专栏
Blog — PlanetScale
Blog — PlanetScale
MongoDB | Blog
MongoDB | Blog
博客园 - 【当耐特】
The GitHub Blog
The GitHub Blog
T
Tenable Blog
W
WeLiveSecurity
Cloudbric
Cloudbric
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
G
Google Developers Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
N
Netflix TechBlog - Medium
F
Full Disclosure
N
News and Events Feed by Topic
D
DataBreaches.Net
P
Proofpoint News Feed
B
Blog RSS Feed
B
Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org

博客园 - 胡枫

ASP.NET URL Rewrite. URL重写 asp.net 中DataGrid自定义分页(简单,实用,易懂) 实现类似textarea这样可以滚动显示内容的方法 各种浏览器CSS hack方法 HTML+CSS+JS学习笔记 JS学习笔记ZT Asp.net 备份、还原Ms SQLServer及压缩Access数据库 我该怎样卸载IE7? ASP.NET Application,Session,Cookie和ViewState等对象用法和区别 (转) ASP读取显示TXT文件内容 ASP.NET 防注入的两个通用函数 innerText,outerText,innerHTML,outerHTML 如何在TextBox控件中显示系统当前时间?包括:年、月、日、时、分 ASP.NET 防注入的两个通用函数 C# 操作ACCESS数据库 asp.net2.0中Repeater的分页使用 ASP.NET2.0下含有DropDownList的GridView编辑、删除的完整例子! 一个GridView编辑删除的例子 asp.net中没有类似asp中Left()函数怎么办?
ASP判断是否包含字符串(InStr 函数)
胡枫 · 2007-11-24 · via 博客园 - 胡枫

asp使用Instr函数来判断一字符串中是否包含另一字符串。

InStr 函数

返回某字符串在另一字符串中第一次出现的位置。

InStr([start, ]string1, string2[, compare])

参数

start

可选项。用于设置每次搜索的开始位置。如果省略,将从第一个字符的位置开始搜索。如果 start 包含 NULL,则会出现错误。如果已指定 compare,则必须要有 start 参数。

string1

必选项。接受搜索的字符串表达式。

string2

必选项。要搜索的字符串表达式。

compare

可选项。指示在计算子字符串时使用的比较类型的数值。有关数值,请参阅“设置”部分。如果省略,将执行二进制比较。

设置

compare 参数可以有以下值:

常数 描述
vbBinaryCompare 0 执行二进制比较。
vbTextCompare 1 执行文本比较。

返回值

InStr 函数返回以下值:

如果 InStr 返回
string1 为零长度 0
string1 为 Null Null
string2 为零长度 start
string2 为 Null Null
string2 没有找到 0
在 string1 中找到 string2 找到匹配字符串的位置
start > Len(string2) 0

说明

下面的示例利用 InStr 搜索字符串:

Dim SearchString, SearchChar, MyPos
SearchString ="XXpXXpXXPXXP"       ' String to search in.
SearchChar = "P"       ' Search for "P".
MyPos = Instr(4, SearchString, SearchChar, 1)
   ' A textual comparison starting at position 4. Returns 6.
MyPos = Instr(1, SearchString, SearchChar, 0)   ' A binary comparison starting at position 1. Returns 9.    
MyPos = Instr(SearchString, SearchChar)   ' Comparison is binary by default (last argument is omitted). Returns 9.
MyPos = Instr(1, SearchString, "W")   ' A binary comparison starting at position 1. Returns 0 ("W" is not found).

注意 InStrB 函数使用包含在字符串中的字节数据,所以 InStrB 返回的不是一个字符串在另一个字符串中第一次出现的字符位置,而是字节位置。

注:使用instr函数时必须给两个字符串加上双引号

如:instr(1,”abcd“,”bc“,1)正确,instr(1,abcd,bc,1)则错误。