Solved

backslash character VBScript runtime error: Syntax error in regular expression

Posted on 2016-09-15
2
37 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.
2 Comments
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 500 total points
Comment Utility
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.
Comment Utility
Simply like that worked.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Well hello again!  Glad to see you've made it this far without giving up.  In this, the fourth installment of my popular series, I'm going to cover functions and subroutines, what they are, and why they are useful.  Just in case you stumbled onto th…
When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
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…

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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now