The string intercept function in the ASP Thief program

Source: Internet
Author: User
Tags first string include split truncated
function | string | Thief program

asp小偷程序中的字符串截取函数

Here's the function code:
’********************************************************************************
' Function (public)
' Name: string intercept function
' Function: intercept content by specified end-end string (This function is truncated from left to right)
' Parameters: scontent----intercepted content
' Sstart------First string
' Istartno----When the first string is not unique, take the first few
' Bincstart---Contains the first string (1/true is included, 0/false is not included)
' Istartcusor-first offset value (number of characters in pointer, negative for left, positive for right bias, 0)
' Sover-------Tail string
' Ioverno-----When the tail string is not unique, take the first few
' bincover----include the tail string (1/true is included, 0/false is not included)
' Iovercusor--tail offset value (number of characters in pointer, negative for left, positive for right bias, 0)
’********************************************************************************
Public Function senfe_cut (scontent, Sstart, Istartno, Bincstart, Istartcusor, Sover, Ioverno, Bincover, Iovercusor)
If scontent<> "" Then
Dim Istartlen, Ioverlen, IStart, Iover, Istartcount, Iovercount, I
Istartlen = Len (sstart) ' first string length
Ioverlen = Len (sover) ' Tail string length
The first occurrence of the first string
IStart = InStr (scontent, Sstart)
' The first occurrence of the tail string on the right side of the first string
Iover = InStr (IStart + Istartlen, scontent, Sover)
If istart>0 and Iover>0 Then
If Istartno < 1 Or isnumeric (istartno) =false Then Istartno = 1
If Ioverno < 1 Or isnumeric (ioverno) =false Then Ioverno = 1
' Gets the number of occurrences of the first string
Istartcount = UBound (Split (scontent, Sstart))
If istartno>1 and Istartcount>0 Then
If istartno>istartcount Then Istartno = Istartcount
For I = 1 to Istartno
IStart = InStr (IStart, Scontent, Sstart) + Istartlen
Next
Iover = InStr (IStart, scontent, Sover)
IStart = Istart-istartlen ' restore default state: Contains a first string
End If
' Gets the number of times the tail string appears
Iovercount = UBound (Split (Mid (scontent, IStart + istartlen), sover))
If ioverno>1 and Iovercount>0 Then
If ioverno>iovercount Then Ioverno = Iovercount
For I=1 to Ioverno
Iover = InStr (Iover, Scontent, sover) + Ioverlen
Next
Iover = Iover-ioverlen ' restore default state: Does not include tail string
End If
If CBool (bincstart) =false Then iStart = iStart + Istartlen ' does not contain a first string
If CBool (bincover) Then iover = iover + Ioverlen ' contains tail string
IStart = IStart + istartcusor ' plus first offset value
Iover = iover + iovercusor ' plus tail offset value
If istart<1 Then IStart = 1
If iover<=istart Then iover = iStart + 1
' Intercept content at specified start and end locations
Senfe_cut = Mid (scontent, IStart, Iover-istart)
Else
' Senfe_cut = scontent
Senfe_cut = "did not find the content you want, you may set the end of the string does not exist!" "
End If
Else
Senfe_cut = "No content!" "
End If
End Function

Here is the sample code:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<title> Arisisi www.alixixi.com string intercept function (intercepting content by specified end-and-end string) </title>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<meta http-equiv= "Content-language" content= "ZH-CN"/>
<meta content= "All" name= "robots"/>
<meta name= "Author" content= "Arisisi, Alixixi"/>
<meta name= "Copyright" content= ""/>
<meta name= "description" content= ""/>
<meta content= "" name= "keywords"/>
<style type= "Text/css" ><!--
* {
font-size:12px;
}
#test {
border-top:1px #000 Solid;
border-left:1px #000 Solid;
}
#test td, #test th {
border-right:1px #000 Solid;
border-bottom:1px #000 Solid;
line-height:200%;
}
--></style>
<script language= "VBScript" ><!--
’********************************************************************************
' Function (public)
' Name: Shengfei string intercept function
' Function: intercept content by specified end-end string (This function is truncated from left to right)
' Parameters: scontent----intercepted content
' Sstart------First string
' Istartno----When the first string is not unique, take the first few
' Bincstart---Contains the first string (1/true is included, 0/false is not included)
' Istartcusor-first offset value (number of characters in pointer, negative for left, positive for right bias, 0)
' Sover-------Tail string
' Ioverno-----When the tail string is not unique, take the first few
' bincover----include the tail string (1/true is included, 0/false is not included)
' Iovercusor--tail offset value (number of characters in pointer, negative for left, positive for right bias, 0)
’********************************************************************************
Public Function senfe_cut (scontent, Sstart, Istartno, Bincstart, Istartcusor, Sover, Ioverno, Bincover, Iovercusor)
If scontent<> "" Then
Dim Istartlen, Ioverlen, IStart, Iover, Istartcount, Iovercount, I
Istartlen = Len (sstart) ' first string length
Ioverlen = Len (sover) ' Tail string length
The first occurrence of the first string
IStart = InStr (scontent, Sstart)
' The first occurrence of the tail string on the right side of the first string
Iover = InStr (IStart + Istartlen, scontent, Sover)
If istart>0 and Iover>0 Then
If Istartno < 1 Or isnumeric (istartno) =false Then Istartno = 1
If Ioverno < 1 Or isnumeric (ioverno) =false Then Ioverno = 1
' Gets the number of occurrences of the first string
Istartcount = UBound (Split (scontent, Sstart))
If istartno>1 and Istartcount>0 Then
If istartno>istartcount Then Istartno = Istartcount
For I = 1 to Istartno
IStart = InStr (IStart, Scontent, Sstart) + Istartlen
Next
Iover = InStr (IStart, scontent, Sover)
IStart = Istart-istartlen ' restore default state: Contains a first string
End If
' Gets the number of times the tail string appears
Iovercount = UBound (Split (Mid (scontent, IStart + istartlen), sover))
If ioverno>1 and Iovercount>0 Then
If ioverno>iovercount Then Ioverno = Iovercount
For I=1 to Ioverno
Iover = InStr (Iover, Scontent, sover) + Ioverlen
Next
Iover = Iover-ioverlen ' restore default state: Does not include tail string
End If
If CBool (bincstart) =false Then iStart = iStart + Istartlen ' does not contain a first string
If CBool (bincover) Then iover = iover + Ioverlen ' contains tail string
IStart = IStart + istartcusor ' plus first offset value
Iover = iover + iovercusor ' plus tail offset value
If istart<1 Then IStart = 1
If iover<=istart Then iover = iStart + 1
' Intercept content at specified start and end locations
Senfe_cut = Mid (scontent, IStart, Iover-istart)
Else
' Senfe_cut = scontent
Senfe_cut = "did not find the content you want, you may set the end of the string does not exist!" "
End If
Else
Senfe_cut = "No content!" "
End If
End Function
--></script>
<script language= "JavaScript" ><!--
Return HTML object by object ID
function $ (ID) {
var obj = document.getElementById (ID);
return obj? obj:undefined;
}
function Test () {
var content = $ ("content"). Value;
var Sstart = $ ("Sstart"). Value;
var Istartno = $ ("Istartno"). Value;
var Bincstart = $ ("Bincstart"). Checked;
var istartcusor = $ ("Istartcusor"). Value;
var sover = $ ("Sover"). Value;
var Ioverno = $ ("Ioverno"). Value;
var bincover = $ ("Bincover"). Checked;
var iovercusor = $ ("Iovercusor"). Value;
if (content== "") {
Alert ("Enter what you want to intercept!") ");
$ ("content"). focus ();
return false;
}
if (sstart== "") {
Alert (Please enter the first string!) ");
$ ("Sstart"). focus ();
return false;
}
if (sover== "") {
Alert ("Please enter the tail string!") ");
$ ("Sover"). focus ();
return false;
}
if (istartno== "" | | | isNaN (ISTARTNO)) istartno=1;
if (ioverno== "" | | | isNaN (ioverno)) ioverno=1;
if (istartcusor== "" | | | isNaN (istartcusor)) istartcusor = 0;
if (iovercusor== "" | | | isNaN (iovercusor)) iovercusor = 0;
$ ("results"). Value = Senfe_cut (content, Sstart, parseint (Istartno), Bincstart, parseint (istartcusor), Sover, parseint ( Ioverno), Bincover, parseint (iovercusor));
$ ("example"). Value = "Scontent = senfe_cut" (\ "content \", \ "first string \", "+istartno+", "+bincstart+", "+istartcusor+", \ "tail string \", "+ Ioverno+ "," +bincover+ "," +iovercusor+ ")";
}
--></script>
<body>
<table id= "test" cellspacing= "0" cellpadding= "0" align= "center" >
<tr><th> Shengfei string intercept function </th></tr>
<tr><td> What to intercept:</td></tr>
<tr><td><textarea name= "Content" id= "content" rows= "cols=" ></textarea></td> </tr>
<tr><td> First String:</td></tr>
<tr><td><textarea name= "Sstart" id= "Sstart" rows= "2" cols= "no" ></textarea></td></ Tr>
<tr><td> take <input type= "text" name= "Istartno" id= "Istartno" value= "1" size= "2"/> <input type= "  CheckBox "Name=" Bincstart "id=" Bincstart "value=" 1 "/> contains a first string? Offset value: <input type= "text" name= "Istartcusor" id= "istartcusor" value= "0" size= "2"/></td></tr>
<tr><td> Tail String:</td></tr>
<tr><td><textarea name= "Sover" id= "Sover" rows= "2" cols= "no" ></textarea></td></tr >
<tr><td> take <input type= "text" name= "Ioverno" id= "Ioverno" value= "1" size= "2"/> <input type= "  CheckBox "Name=" Bincover "id=" Bincover "value=" 1 "/> contains a first string? Offset value: <input type= "text" name= "Iovercusor" id= "iovercusor" value= "0" size= "2"/></td></tr>
<tr><td><input type= "button" name= "Submit" value= "test"/></td></tr>
<tr><td> return Results:</td></tr>
<tr><td><textarea name= "Results" id= "results" rows= "ten" cols= "></textarea></td>" </tr>
<tr><td> Call Example:</td></tr>
<tr><td><textarea name= "Example" id= "Example" rows= "2" cols= "></textarea></td>" </tr>
</table>
</body>



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.