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

  • SEARCH
  • Home
  • 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 6961447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:31:53+00:00 2026-05-27T15:31:53+00:00

I want to convert some VB.NET code for regular expression to F#. The following

  • 0

I want to convert some VB.NET code for regular expression to F#.
The following code works in VB.NET:

Dim regOpts As RegexOptions = RegexOptions.IgnoreCase Or RegexOptions.Singleline
Dim r As New Regex("<a[^>]*href\s*=\s*""?(?<HRef>[^"">\s]*)""?[^>]*>", regOpts)

But the corresponding code in F# can not get complied:

open System.Text.RegularExpressions
let regOpts: RegexOptions = RegexOptions.IgnoreCase ||| RegexOptions.Singleline
let reg = new Regex("<a[^>]*href\s*=\s*""?(?<HRef>[^"">\s]*)""?[^>]*>", regOpts)

I got the compiler error:

Error: This value is not a function and cannot be applied

I believe F# does NOT recognize the double quote inside double quote, but for VB.NET, it is OK, my code work correctly. Please show me how to modify the F# code, so it can work.

  • 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-05-27T15:31:53+00:00Added an answer on May 27, 2026 at 3:31 pm

    Just escape the " as \" as described here, instead of the VB.NET escape (that doubles them).

    let reg = new Regex("<a[^>]*href\s*=\s*\"?(?<HRef>[^\">\s]*)\"?[^>]*>", regOpts)
    

    Though a better option might be to change it to a verbatim string literal:

    let reg = new Regex(@"<a[^>]*href\s*=\s*""?(?<HRef>[^"">\s]*)""?[^>]*>", regOpts)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to convert a string into a double and after doing some math
I have some html files that I want to convert to text. I have
I want some particular urls like springer.com to automatically convert to springer.com.proxy1.mycollege.edu. The second
I've written some tests for .net code that invokes calls to my SQL Server.
I am trying to refactor some code in an ASP.Net website and having a
I'm trying to convert some code that worked great in VB, but I can't
I have some existing code that retrieves data from a database using ADO.NET that
I want to use some of the new features of mshtml.dll version 9.0 such
I have some code in .Net to draw some text content using GDI+. I
I am using AJAX.NET's update panels in the below manner. My code works perfect

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.