?
Solved

backslash character VBScript runtime error: Syntax error in regular expression

Posted on 2016-09-15
2
Medium Priority
?
112 Views
Last Modified: 2016-09-15
Hello I´m using a a VBscript to search 2 strings in the middle of one.

Set oRE = CreateObject("vbscript.regexp")
oRE.Global = True
oRE.Pattern = "\activ\(.*?)\vid"

Open in new window


In this test the script need to search for strings "\activ\" and "\vid"

Now I received the error when I run the VBscript via command prompt with cscript: "VBScript runtime error: Syntax error in regular expression"

Now I see the backslash "\" characters are not accepted to search in the string. I tested the script with letters and numbers including normal "/" and works but how can I modify the script to accept in the search string and search also "\" backslash characters?

Thank you
0
Comment
Question by:Alex E.
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 93

Accepted Solution

by:
Patrick Matthews earned 2000 total points
ID: 41800071
Backslash is a reserved character, and you have to escape it with an extra backslash.  Like so:

oRE.Pattern = "\\activ\\(.*?)\\vid"

Open in new window


You may also be interested in this article on using the VBScript implementation of RegExp.
0
 

Author Closing Comment

by:Alex E.
ID: 41800107
Simply like that worked.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Suggested Courses
Course of the Month14 days, 23 hours left to enroll

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question