使用正则表达式实现模式图片新闻.ASP

寳爱话

寳爱话

2016-01-29 18:53

使用正则表达式实现模式图片新闻.ASP,使用正则表达式实现模式图片新闻.ASP
 

'文字或特定图片模式显示新闻

function shownew(content,ntype)

shownew = ""

(本文来源于图老师网站,更多请访问https://m.tulaoshi.com/asp/)

if(ntype = 1) then

shownew = shownew &" <TABLE width=100% "
shownew = shownew &"<TR"
shownew = shownew &" <TD width=600 style='word-break:break-all' valign=top"&ShowPic(content)&"</TD"
shownew = shownew &"</TR"
shownew = shownew &"<TR"
shownew = shownew &" <TD valign=top style='word-break:break-all'"&OnlyWord(content)&"</TD"
shownew = shownew &"</TR"
shownew = shownew &"</TABLE"


elseif (ntype = 2) then

(本文来源于图老师网站,更多请访问https://m.tulaoshi.com/asp/)


shownew = shownew &" <TABLE width='100%'"

shownew = shownew &"<TR"
shownew = shownew &" <TD style='word-break:break-all' valign=top"&OnlyWord(content)&"</TD"
shownew = shownew &"</TR"
shownew = shownew &"<TR"
shownew = shownew &" <TD  width=600 valign=top style='word-break:break-all'"&ShowPic(content)&"</TD"
shownew = shownew &"</TR"
shownew = shownew &"</TABLE"

elseif (ntype = 3) then


shownew = shownew &"<TABLE"

shownew = shownew &"<TR"
 shownew = shownew &"<TD width=100 valign=top"&ShowPic(content)&"</TD"

 shownew = shownew &"<TD width=80% style='word-break:break-all' valign=top"&OnlyWord(content)&"</TD"


shownew = shownew &"</TR"
shownew = shownew &"</TABLE"

elseif (ntype = 4) then

shownew = shownew &"<TABLE"

shownew = shownew &"<TR"

  shownew = shownew &"<TD width=80% valign=top style='word-break:break-all'"&OnlyWord(content)&"</TD"
 shownew = shownew &"<TD width=100  valign=top"&ShowPic(content)&"</TD"

shownew = shownew &"</TR"
shownew = shownew &"</TABLE"
else
 shownew = shownew & "<table<tr<td style='word-break:break-all'"&content&"</td</tr</table"
end if

end function

'显示提取的图片
function ShowPic(strng)

 ShowPic = ""
 ImageUrl= RegExpExecute(strng)

 ImageUrls = Split(ImageUrl,"<BR")

 for i = LBound(ImageUrls) to (UBound(ImageUrls) - 1)

    ShowPic = ShowPic & ("<a href='"&ImageUrls(i)&"' target=_blank<image src="http://img.jcwcn.com/attachment/portal"&ImageUrls(i)&"' border='0' alt='按此在新窗口浏览图片' onload='javascript:if(this.width180)this.width=180'</a")

    next
 
end function


'从内容中提取图片
Function RegExpExecute(strng)
    Dim regEx, Match, Matches '建立变量。
    Set regEx = New RegExp '建立正则表达式。
      regEx.Pattern = "(src="http://img.jcwcn.com/attachment/portal"&CHR(34)&"| )?(.[^'|s|"&CHR(34)&"]*)(.)(jpg|gif|png|bmp|jpeg)('|"&CHR(34)&"|s|)?" '设置模式。
   ' regEx.Pattern = "(src="http://img.jcwcn.com/attachment/portal"&CHR(34)&"| )?(.[^'| |"&CHR(34)&"]*)(.)(jpg|gif|png|bmp|jpeg)('|"&CHR(34)&"| |)?" '设置模式。
    'regEx.Pattern = "(s|S)(r|R)(c|C)=('|"+CHR(34)+")(w|\|/|.)+('|"+CHR(34)+"| *|)?" '设置模式。
    regEx.IgnoreCase = true '设置是否区分字符大小写。
    regEx.Global = True '设置全局可用性。
    Set Matches = regEx.Execute(strng) '执行搜索。
    For Each Match in Matches '遍历匹配集合。
       values=values&Match.SubMatches(2)&Match.SubMatches(3)&Match.SubMatches(4)&"<BR"
    Next
   RegExpExecute = values
End Function

'删除内容中与图片有关的代码
function OnlyWord(strng)
  Set re=new RegExp
  re.IgnoreCase =Tru

展开更多 50%)
分享

猜你喜欢

使用正则表达式实现模式图片新闻.ASP

ASP
使用正则表达式实现模式图片新闻.ASP

正则表达式的使用 ASP

Web开发
正则表达式的使用 ASP

s8lol主宰符文怎么配

英雄联盟 网络游戏
s8lol主宰符文怎么配

ASP正则表达式详解

ASP
ASP正则表达式详解

JavaScript 实现基础 正则表达式

Web开发
JavaScript 实现基础 正则表达式

lol偷钱流符文搭配推荐

英雄联盟 网络游戏
lol偷钱流符文搭配推荐

正则表达式

Web开发
正则表达式

正则表达式口诀 正则表达式学习工具

Web开发
正则表达式口诀 正则表达式学习工具

lolAD刺客新符文搭配推荐

英雄联盟
lolAD刺客新符文搭配推荐

利用XSL和ASP实现XML文档在线编辑

利用XSL和ASP实现XML文档在线编辑

ASP上两个防止SQL注入式攻击Function

ASP上两个防止SQL注入式攻击Function
下拉加载更多内容 ↓