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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:29:00+00:00 2026-06-14T08:29:00+00:00

I have a substring that may or may not exist in a larger string,

  • 0

I have a substring that may or may not exist in a larger string, and if it does it should contain some contact information that I want to grab with a regular expression.

Due to message parameters beyond my control, this substring may sometimes be truncated, so I’ve written a couple different regular expressions to accommodate for each scenario.

The problem I’m running into is that the more complicated expressions die on me. These expressions have run just fine on every Regex testing website that I’ve tried.

Here’s a code clip for reference.

' Look for contact information using regular expressions.  Data we're looking for is in the format below
' "-- Contact: [name] [email] [phone]"
Dim ContactPattern As String
Dim ContactMatch As Match

If SomeStuff Then
' Only look for the [name] block
ContactPattern = "((?:-- Contact: \[)((\w*|\W*|\s*|\S*)*)\])"
' This match attempt works fine.
ContactMatch = Regex.Match(FullString, ContactPattern, RegexOptions.None)

' Do stuff with the results

ElseIf SomeOtherStuff Then
' Look for [name] and [email]
ContactPattern = "((?:-- Contact: \[)((\w*|\W*|\s*|\S*)*)\] \[((\w*|\W*|\s*|\S*)*)\])"
' This match attempt does not get processed.  I receive the message below in the output window.
'The thread '<No Name>' (0x1f58) has exited with code 0 (0x0).
ContactMatch = Regex.Match(FullString, ContactPattern, RegexOptions.IgnoreCase)

' Do stuff with the results

ElseIf SomeOtherOtherStuff Then
' Look for [name] [email] and [phone]
ContactPattern = "((?:-- Contact: \[)((\w*|\W*|\s*|\S*)*)\] \[((\w*|\W*|\s*|\S*)*)\] \[((\w*|\W*|\s*|\S*)*)\])"
' This match attempt does not get processed.  I receive the message below in the output window.
' "The thread '<No Name>' (0x1f58) has exited with code 0 (0x0)."
ContactMatch = Regex.Match(FullString, ContactPattern, RegexOptions.None)

' Do stuff with the results

End If

Unfortunately Google has failed me (or I’ve failed it). Does anyone have any thoughts? Again, the regular expressions themselves evaluate successfully on Regex test sites.

  • 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-14T08:29:02+00:00Added an answer on June 14, 2026 at 8:29 am

    You have probably encountered catastrophic backtracking. Your regexes contain nested repetitions of patterns that are not mutually exclusive. Especially (\w*|\W*|\s*|\S*)* does not make any sense. \w and \W in combination contain all characters. So do \s and \S. Also the inner asterisks do not accomplish anything, because the outer repetition can take care of that as well.

    If, what you want to accomplish, really is to match any character there, you can simply replace every (\w*|\W*|\s*|\S*)* by [\s\S]*. Alternatively .* in combination with RegexOptions.Singleline does the same.

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

Sidebar

Related Questions

I have a bunch of strings that may or may not have a substring
I have a string like myweb.com/blabla/blabla/image.jpg How could I get substring that starts at
I have a string s and I want to search for the substring of
I have a string which may or may not end with whitespace and I'm
My problem is that I have a string in javascript and the string may
I have two files Which should contain the same values between Substring 0 and
I have a field in my table that holds a string denoting some object
I have a string that may be longer than any simple int boundaries. Currently,
I have a function that builds substrings given a string recursively. Could anyone please
I have a string and start and length with which to extract a substring.

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.