We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now


Help with RegExp conversion from PhP to VB

philggg asked
Medium Priority
Last Modified: 2010-04-07
I am transfering over a regular expresion from php to VB (I am using it to block cross site scripting on a web page)
The original php epresion is:
$string = preg_replace('#(<[^>]+)style[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*).*expression[\x00-\x20]*\([^>]*>#iU',"$1>",$string);

My VB version using RegExp
regex.Pattern = "#([a-z]*)[\x00-\x20]*=[\x00-\x20]*([\`\'\""]*)[\\x00-\x20]*j[\x00-\x20]*a[\x00-\x20]*v[\x00-\x20]*a[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iU"
oldstring = regex.Replace(oldstring, "$1=$2nojavascript...>")
(note I replaced the single apostrophe with a double)
I get a very unhelpful error from VB:
Application-defined or object-defined error

Two questions:
What is wrong with my pattern?
How do I get more helpful error messages out of RegExp?

Watch Question

Please try this

regex.Pattern = "#([a-z]*)[\x00-\x20]*=[\x00-\x20]*([\`\'\" & chr(34) & chr(34) & _

I hope this will help u.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Hi Phil,

I noticed your 3rd block of hex 0-20 has two \ symbols, that should only be one:


The rest of it looks syntactically correct at least.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.