Directly replace with regularity, but no judgment function
Function FormatImg(content)
dim re
Set re=new RegExp
=true
=True
="(script)"
Content=(Content,"script")
="<img.[^>]*src(=| )(.[^>]*)>"
Content=(Content,"<img src=$2 style=""cursor: pointer"" alt=""Open in a new window to browse"" onclick=""javascript:();"" onload=""javascript:resizepic(this)"" border=""0""/>")
set re = nothing
FormatImg = content
End Function
This code replaces the image in the content with <img src=$2 style="cursor: pointer" alt="Open in a new window to browse" onclick="javascript:();" onload="javascript:resizepic(this)" border="0"/> In this form,
I now need to extract the first 7 characters of $2 to determine whether it needs to be replaced. If the first 7 = specific characters, don't replace it, but getting the first 7 of $2 cannot. What are the ways for everyone to help?
Mainly refer to the following code, you can read it
'connect
= "\[url=(.[^\]]*)\](.[^\[]*)\[\/url]"
Set strMatchs=(strContent)
For Each strMatch in strMatchs
tmpStr1=checkURL((0))
tmpStr2=(1)
strContent=replace(strContent,,"<a target=""_blank"" href="""&tmpStr1&""">"&tmpStr2&"</a>",1,-1,0)
Next
Here is the documentation for regular Matchs
https:///article/
Below I will test the code, you can make functions
<%
content2="<img src='https:///images/' width=100 /> Some content in the middle<img src='/indeximg/' width=200 />"
dim re
Set re=new RegExp
=true
=True
="<img.[^>]*src(=| )(.[^>]*)[/]?>"
set Matches=(content2)
For Each strMatch in Matches
tmpStr1=((1))
tmpurl=replace(replace(tmpStr1,"'",""),"""","")
// left(tmpurl,20)
if left(tmpurl,19)="https://" then
picurl=tmpurl
else
picurl="http://img./?url="&tmpurl
end if
Content=replace(Content2,,"<img src="&picurl&" style=""cursor: pointer"" alt=""Open in a new window to browse"" onclick=""javascript:();"" onload=""javascript:resizepic(this)"" border=""0""/>")
Next
Content
set re = nothing
%>
Function FormatImg(content)
dim re
Set re=new RegExp
=true
=True
="(script)"
Content=(Content,"script")
="<img.[^>]*src(=| )(.[^>]*)>"
Content=(Content,"<img src=$2 style=""cursor: pointer"" alt=""Open in a new window to browse"" onclick=""javascript:();"" onload=""javascript:resizepic(this)"" border=""0""/>")
set re = nothing
FormatImg = content
End Function
This code replaces the image in the content with <img src=$2 style="cursor: pointer" alt="Open in a new window to browse" onclick="javascript:();" onload="javascript:resizepic(this)" border="0"/> In this form,
I now need to extract the first 7 characters of $2 to determine whether it needs to be replaced. If the first 7 = specific characters, don't replace it, but getting the first 7 of $2 cannot. What are the ways for everyone to help?
Mainly refer to the following code, you can read it
'connect
= "\[url=(.[^\]]*)\](.[^\[]*)\[\/url]"
Set strMatchs=(strContent)
For Each strMatch in strMatchs
tmpStr1=checkURL((0))
tmpStr2=(1)
strContent=replace(strContent,,"<a target=""_blank"" href="""&tmpStr1&""">"&tmpStr2&"</a>",1,-1,0)
Next
Here is the documentation for regular Matchs
https:///article/
Below I will test the code, you can make functions
<%
content2="<img src='https:///images/' width=100 /> Some content in the middle<img src='/indeximg/' width=200 />"
dim re
Set re=new RegExp
=true
=True
="<img.[^>]*src(=| )(.[^>]*)[/]?>"
set Matches=(content2)
For Each strMatch in Matches
tmpStr1=((1))
tmpurl=replace(replace(tmpStr1,"'",""),"""","")
// left(tmpurl,20)
if left(tmpurl,19)="https://" then
picurl=tmpurl
else
picurl="http://img./?url="&tmpurl
end if
Content=replace(Content2,,"<img src="&picurl&" style=""cursor: pointer"" alt=""Open in a new window to browse"" onclick=""javascript:();"" onload=""javascript:resizepic(this)"" border=""0""/>")
Next
Content
set re = nothing
%>