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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:04:11+00:00 2026-06-07T15:04:11+00:00

I am trying to separate the following string into a separate lines with regular

  • 0

I am trying to separate the following string into a separate lines with regular expression

[property1=text1][property2=text2] 

and the desired result should be

property1=text1
property2=text2

here is my code

string[] attrs = Regex.Split(attr_str, @"\[(.+)\]");

Results is incorrect, am probably doing something wrong

enter image description here

UPDATE: after applying the suggested answers. Now it shows spaces and empty string

enter image description here

  • 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-07T15:04:13+00:00Added an answer on June 7, 2026 at 3:04 pm

    .+ is a greedy match, so it grabs as much as possible.

    Use either

    \[([^]]+)\]
    

    or

    \[(.+?)\]
    

    In the first case, matching ] is not allowed, so “as much as possible” becomes shorter. The second uses a non-greedy match.

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

Sidebar

Related Questions

i am trying to split a string up into separate lines with the following
Trying to split this string 主楼怎么走 into separate characters (I need an array) using
I'm trying to separate the month and day from the following string. 2012-06-29 I've
I have following URL string /category/category1/2010/12/10/id I need to separate string into parts. I'm
I am trying to separate a large table into multiple discrete types. I'm following
I'm trying to write a library to separate all the disk activity out into
I'm trying to output a string from an Object that has been passed into
I am trying to separate a few things in here. I have a program
I am trying to separate my logic for better readability and re-useability. I am
I'm trying to basically trying to separate a specific amount of text from 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.