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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:31:19+00:00 2026-06-13T13:31:19+00:00

I have a file formatted like this: hello = { a = 2354a b

  • 0

I have a file formatted like this:

hello = {

     a = "2354a"
     b = "06567567h"


}

goodbye = {
     there = "/home/afhge"

}

...

anotherset = {
      dsfsdf = grhbrwecs
      dfgtmyj = 12345

}

I am using regular expressions in python, what I want matched is everything inside the braces so the resulting match output would be the following list:

['\n\n\ta = "2345a"\n\tb = "06567567h"\n\n\n', '\n\there = "/home/afhge"\n\n', '\n\tdsfsdf = grhbrwecs\n\tdfgtmyj = 12345\n\n']

I have tried the regex:

desired_output = re.findall("{[^}]", file_text)

however this regex results in the list:

['{\n', '{\n', '{\n', '{\n', '{\n']

It looks like [^}] matches any character up until a newline. I’ve tried doing:

desired_output = re.findall("{[^}]", file_text, re.S)

and

desired_output  = re.findall("{[^}]", file_text, re.M)

To no success :(.

Thanks!

  • 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-13T13:31:19+00:00Added an answer on June 13, 2026 at 1:31 pm

    No your character class is right. It will match any character that is not } (even line breaks). The problem is that [^}] matches only one character. Simply use a repetition quantifier (and you should probably escape the {):

    r"\{[^}]*"
    

    Regarding the options you tried. If anything re.S would help, because without it . does not match line breaks. But the . is really the only thing affected by re.S. The other option re.M has nothing to with it. That just makes the anchors ^ and $ match at line beginnings and ends as well.

    Also, since you only want the content within the brackets, you don’t need to match the { itself, but you could use a lookbehind instead:

    r"(?<=\{)[^}]*"
    

    This will not include the { in the match.

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

Sidebar

Related Questions

I have a CSV file formatted just like this: name,color,tasty,qty apple,red,true,3 orange,orange,false,4 pear,greenish-yellowish,true,1 As
I have a text file, that is formatted somewhat like this: 1 2 3
I have a huge tab-separated file formatted like this X column1 column2 column3 row1
So I have an xml file that is formatted something like this <TopXmlTree> <IndentedItem1>
I have an XML file formatted like this: <?xml version=1.0 encoding=utf-8?> <Snippets> <Snippet name=abc>
Say I have a text file formatted like this: 100 20 the birds are
I have a CSV file, formatted like this: 0001 @ word @ some information
I have a text file with hundreds of entries formatted like this, I need
Suppose I have a tab delimited file containing user activity data formatted like this:
I have a dictionary file formatted like this: A B [C] D Where a

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.