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 4013584
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:23:23+00:00 2026-05-20T09:23:23+00:00

I am converting VBA code that contains the LIKE operator, as in dim sToken

  • 0

I am converting VBA code that contains the LIKE operator, as in

    dim sToken as String
    if sToken Like "(*,*)" then ...

In all cases the patterns use only the * wildcard which matches any string (including the empty string). The VBA Like operator yields only a true/false result so it’s up to the subsequent VBA code to parse further and pluck out the matching substrings whenever there’s a match.

I’d be most appreciative if someone can provide a C# snippet to test for the same type of simple wildcard match. If the snippet also yields matching substrings – even better.

  • 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-20T09:23:23+00:00Added an answer on May 20, 2026 at 9:23 am

    Well, that particular pattern could be matched with

    if (sToken.StartsWith("(") && sToken.EndsWith(")")
        && sToken.Contains(","))
    

    but in general you may find it makes more sense to use regular expressions. For example:

    using System;
    using System.Text.RegularExpressions;
    
    class Program
    {
        static void Main(string[] args)
        {
            Regex regex = new Regex(@"^\(.*,.*\)$");
    
            Console.WriteLine(regex.IsMatch("x(a,b)")); // False due to the x
            Console.WriteLine(regex.IsMatch("(a,b)x")); // False due to the x
            Console.WriteLine(regex.IsMatch("(ab)"));   // False due to the lack of ,
            Console.WriteLine(regex.IsMatch("(a,b"));   // False due to the lack of )
            Console.WriteLine(regex.IsMatch("(a,b)"));   // True!
            Console.WriteLine(regex.IsMatch("(aaa,bbb)"));   // True!
            Console.WriteLine(regex.IsMatch("(,)"));   // True!
        }
    }
    

    Things to note with the pattern here:

    • I’ve used a verbatim string literal (the @ at the start) to make it easier to perform escaping within the regex
    • ^ and $ force it to match the whole string
    • The brackets are escaped so they’re not treated as grouping operators

    The MSDN “Regular Expression Language Elements” page is a good reference for .NET regexes.

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

Sidebar

Related Questions

While converting an old code, I encountered the following problem. Given an HTML string,
Converting numbers to strings is no problem, but the string created uses ascii numbers.
Converting a database of people and addresses from ALL CAPS to Title Case will
Converting from Django, I'm used to doing something like this: {% if not var1
We're converting some .NET 3.5 code to Java (Android). This Java code gives the
I'm currently converting some legacy code to create PDF files using iTextSharp. We're creating
We are converting a C++ math library to C#. The library mixes the use
While converting a desktop application to a web app, I've run across my ignorance
I am converting some docs to pdf using wkhtmltopdf (currently using perl and the
I am converting some environment variables to property sheets for some C++ projects. This

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.