Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8279179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:14:52+00:00 2026-06-08T09:14:52+00:00

I have some regex code originally written in PHP and I need to port

  • 0

I have some regex code originally written in PHP and I need to port this to ASP. Here is the original PHP code:

$contents = file_get_contents("http://localhost/source.txt");
$title =  'My Title';
preg_match("/<b>$title.*?(<p.*?)<\/td/smi",$contents,$matches);
print_r($matches);

And here is the ASP ported version:

contents = File_Get_Contents("http://localhost/source.txt")
response.write contents
title = "My Title"
regex = "<b>" + title + ".*?(<p.*?)</td"
Set objRE2 = New RegExp
With objRE2
    .Pattern    = regex
    .IgnoreCase = True
    .Global     = True
    .MultiLine  = True
End With

Set myMatches = objRE2.Execute(contents)
'myMatches - Count is 0

Function File_Get_Contents(strFile)
    ' Remote File
    If Left(strFile, 7) = "http://" Or Left(strFile, 8) = "https://" Then
        'Set objXML = Server.CreateObject("Microsoft.XMLHTTP")
        ' Use this line if above errors
        Set objXML = Server.CreateObject("MSXML2.ServerXMLHTTP")
        objXML.Open "GET", strFile, False
        objXML.Send()
        File_Get_Contents = objXML.ResponseText
        Set objXML = Nothing
    ' Local File
    Else
        Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
        Set objFile = objFSO.OpenTextFile(strFile, 1)
        File_Get_Contents = objFile.ReadAll()
        Set objFile = Nothing
        Set objFSO = Nothing
    End If
End Function

source.txt:

<td>
<b>My Title</b><br>
<p>My Content</p></td>

If I write out the actual regex pattern in both languages, it’s the same except for the escaping of the forward slash character in the PHP version. (I’ve also tested adding this, with the same effect).

Is there some subtle difference in the regexes that I am missing or is it some silly mistake I just can’t see?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T09:14:56+00:00Added an answer on June 8, 2026 at 9:14 am

    There are a number of differences between .NET and PHP regular expressions.1. However ASP-Classic’s use of regular expressions is far older, and less well documented.

    Assuming this Scripting Clinic article Microsoft Beefs Up VBScript with Regular Expressions is correct then you will need to re-write your expression.

    To start with there is no support for “minimal matching” with *?, ?? and +?.


    1 Compare tables 9-1 and 10-1 of Mastering Regular Expressions (3rd edition).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some Regex, it looks like this: string regexForDrop = @^((%27)|'|(\-\-))\s*(d|%64|%44)(r|%72|%52)(o|%6F|%4F)(p|%70|%50)$; It works
While doing some small regex task I came upon this problem. I have a
I need some help writing a regex. I have the following strings, xxx.yyy.wwwwwaaa_IN_123 xxx.rrrttttt_IN_12355
am having problems with some Regex code can anyone help. I have the following
I have some JavaScript, which is generated by PHP code, using a template. The
I have some code like this, which replaces some shortcodes with a link: $search
I have some php code that contains regular expressions and I was wondering what
I have code like this string pattern = <(.|\n)+?>; System.Text.RegularExpressions.Regex regEx = new System.Text.RegularExpressions.Reg(pattern);
I have some code to create a Virtual Directory programmatically. I need to edit
I have some broken html-code that i would like to fix with regex. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.