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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:23:10+00:00 2026-05-23T06:23:10+00:00

Given the following type of string: #First Thing# #Another One##No Space# Main String #After

  • 0

Given the following type of string:

“#First Thing# #Another One##No Space# Main String #After Main# #EndString#”

I would like to come up with a regular expression that can return all the text surrounded by the # symbols as matches. One of the things giving me grief is the fact that the # symbol is both the opening and closing delimiter. All of my attempts at a regex have just returned the entire string. The other issue is that it is possible for part of the string to not be surrounded by # symbols, as shown by the substring “Main String” above. Does anyone have any ideas? I have toyed around with Negative Look-behind assertion a bit, but haven’t been able to get it to work. There may or may not be a space in between the groups of #’s but I want to ignore them (not match against them) if there are. The other option would be to just write a string parser routine, which would be fairly easy, but I would prefer to use a regex if possible.

  • 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-23T06:23:11+00:00Added an answer on May 23, 2026 at 6:23 am

    [Edit]

    I think that this is what you need:

    (?<=#)[^#]+?(?=#)
    

    With input #First Thing# #Another One##No Space# Main String #After Main# matches:

    • First Thing
    • Another One
    • No Space
    • Main String
    • After Main

    The second match is the space between Thing# and #Another.

    [EDIT] To ignore space:

    (?<=)(?!\s+)[^#]+?(?=#)
    

    If you want to ignore trailing spaces:

    (?<=)(?!\s+)[^#]+?(?=\s*#)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given I have code like the following: void foo() { String str = hello;
Given the following XML: <current> <login_name>jd</login_name> </current> <people> <person> <first>John</first> <last>Doe</last> <login_name>jd</login_name> </preson> <person>
Given the following: List<List<Option>> optionLists; what would be a quick way to determine the
The question more or less says it all. Given the following record structure: type
Ok, consider the following code: private const int THRESHHOLD = 2; static void Main(string[]
I got the following error when executing bulkcopy. System.InvalidOperationException The given value of type
Given the following code: .section .rodata input_format: .string %d output_format1: .string output_format2: .string .section
The following code gives me the errors: Cannot implicitly convert type T to string.
Suppose I have a given object of type IEnumerable<string> which is the return value
Given the following declaration: <Extension()> Public Function ToJSON(ByVal target As Object) As String Dim

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.