弘帝企业智能建站系统交流平台

 找回密码
 立即注册
查看: 2126|回复: 0

【正则】如何提取指定范围内的字符串

[复制链接]
发表于 2017-5-22 09:27:52 | 显示全部楼层 |阅读模式
这里以ASP为例:查找{}里的字符串内容,不含{}本身。
    Set RegEx = New RegExp            '建立一般表达式。
    RegEx.IgnoreCase = True           '设置是否区分大小写。
    RegEx.Global = True               '设置全局可用性。
    RegEx.Pattern = "\{(.*)\}"
    Set Matches = RegEx.Execute(StringTemplate)
    For Each Match In Matches               '重复匹配集合
'Match.Value 是包括{}的
        StringReference = RegEx.Replace(Match.Value, "$1")
'StringReference是去掉{}后的字符串
        Set Rs = New ADODB.Recordset
        Sql = "SELECT * FROM HD_PreOrder_Property WHERE HD_CompanyID=" & Session("CompanyID")
        StringTemplate = Replace(StringTemplate, StringReference, "sssss")
    Next
    Response.write StringTemplate


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|弘帝企业智能建站系统 ( 皖ICP备07503252号 )

GMT+8, 2024-4-24 05:44 , Processed in 0.094454 second(s), 15 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表