如何判断程序中有2段后,在段与段之间加个分界标志

china165 2005-05-12 01:53:22
比如,每一段是这样的
<P>1</P>
<P>2</P>
<P>3</P>
<P>4</P>

我要每隔二段加一个<br>怎么搞啊?

怎么判断出这个文章里有几段?然后增加一个<br>

...全文
78 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
goodstuday 2005-05-12
  • 打赏
  • 举报
回复
do while RegExp_Test(patrn,str)=true
if i<>0 and i mod 2=0 then
str=RegExp_Replace(patrn,str,"</P><br>")
end if
i=i+1
loop
china165 2005-05-12
  • 打赏
  • 举报
回复
也就是每过二个加一个BR
china165 2005-05-12
  • 打赏
  • 举报
回复
i=0
do while RegExp_Test(patrn,str)=true
str=RegExp_Replace(patrn,str,"</P><br>")
i=i+1
loop

我要在2与3之间加个<br>呀
goodstuday 2005-05-12
  • 打赏
  • 举报
回复
最后输出就是了
Response.Write Str&"<br>"&i
goodstuday 2005-05-12
  • 打赏
  • 举报
回复

str="<P>1</P><P>2</P><P>3</P><P>4</P>"
patrn="<\/P>"
i=0
do while RegExp_Test(patrn,str)=true
str=RegExp_Replace(patrn,str,"</P><br>")
i=i+1
loop
Function RegExp_Test(patrn, strng)
Dim regEx
Dim matches
Set regEx = New RegExp ' 建立正则表达式。
regEx.Pattern = patrn ' 设置模式。
regEx.IgnoreCase = true' 设置是否区分字符大小写。
regEx.Global = True ' 设置全局可用性。
matches = regEx.test(strng)
RegExp_Test = matches
End Function
Function RegExp_Replace(patrn,str,replStr)
Dim regEx ' 建立变量。
Set regEx = New RegExp ' 建立正则表达式。
regEx.Pattern = patrn ' 设置模式。
regEx.IgnoreCase = true ' 设置是否区分大小写。
RegExp_Replace = regEx.Replace(str,replStr) ' 作替换。
End Function
lightenvoy 2005-05-12
  • 打赏
  • 举报
回复
instr()
然后判断位置,取左右字符串,并上"<br>"

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧