VBScript-替换出现在“,”和“,”之间的所有逗号

时间:2019-12-19 08:24:41

标签: regex vbscript

使用VBScript,我需要替换,“ 之间的所有逗号(即chr(34)&chr(44)和chr(44)&chr( 34)),并用点将其转换为输入下方的输出字符串。不在这些字符之间的逗号应保留。

buildscript {
    dependencies {
        classpath "io.spring.gradle:dependency-management-plugin:0.5.2.RELEASE"
    }
}

apply plugin: "io.spring.dependency-management"

dependencyManagement {
     imports {
          mavenBom "org.springframework.cloud:spring-cloud-sleuth:${springCloudSleuthVersion}"
     }
}
dependencies {
    compile 'org.springframework.cloud:spring-cloud-starter-sleuth'
}

非常感谢。

1 个答案:

答案 0 :(得分:1)

您可以使用以下方法在VBScript中使用正则表达式。

Public Sub TestRegex()
    Dim ip
    ip = "2019/011,05-11-2019,05-11-2019,""748,845,914,968,1019,1081"",Edward Norton,86105015751000009077333566,,""5846,03"",,""548,95"",20,T"

    Dim RE
    Set RE = new RegExp

    RE.Pattern = "\""[\d,]+\"""
    RE.Global = True
    RE.IgnoreCase = True
    Set allMatches = RE.Execute(ip)

    outStr = ip
    For Each Match In allMatches
        m = Mid(outStr, Match.FirstIndex + 1, Match.Length)
        outStr = Replace(outStr, m, Replace(m, ",", "."))
    Next
    WScript.Echo outStr
End Sub