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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:08:10+00:00 2026-06-06T05:08:10+00:00

I am using Pattern and Matcher classes from Java to parse a link file

  • 0

I am using Pattern and Matcher classes from Java to parse a link file script.
The text I need is in the SECTIONS part:

SECTIONS
    {
        .text : {} > FAST_MEM /* Link all .text sections into ROM */
        .intvecs : {} > 0x0 /* Link interrupt vectors at 0x0 */
        .data : /* Link .data sections */
        {
            tables.obj(.data)
            . = 0x400; /* Create hole at end of block */
        } = 0xFF00FF00 > EEPROM /* Fill and link into EEPROM */
        ctrl_vars: /* Create new ctrl_vars section */
        {
            ctrl.obj(.bss)
        } = 0x00000100 > SLOW_MEM /* Fill with 0x100 and link into RAM */
        .bss : {} > SLOW_MEM /* Link remaining .bss sections into RAM */
    }

right now I am using

Pattern SectPattern = Pattern.compile("(SECTIONS\\{(.*)\\})");

and I want to extract the (.*) group but the result is not what I expected
Does anyone have any ideas of a better pattern to use?

  • 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-06T05:08:15+00:00Added an answer on June 6, 2026 at 5:08 am

    This will match and print the content inside SECTIONS { and }.:

    Pattern pattern = Pattern.compile("SECTIONS.*?\\{(.*)\\}", Pattern.DOTALL);
    Matcher matcher = pattern.matcher(sample);
    matcher.find();
    
    System.out.println(matcher.group(1));
    

    where sample is your pattern sample. Pattern.DOTALL is required to handle line breaks correctly, the others should be self-explanatory.

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

Sidebar

Related Questions

I am developing a text highlighter in a file using the java regex pattern
I am using while(matcher.find()) to loop through and retrieve things from a file. I
I've got a code which involves using Matcher and Pattern classes, however I've got
Need to parse a Class declaration line in Java using regular expression e.g. String
I am using the matches string builtin and need to run a regex pattern
Im am using a pattern from the book Learning Cocos2D. I have a GameState
I tried this regex in Java : Pattern orderCheck = Pattern.compile("^([\\-\\+])?(created|title|price|creation)$", Pattern.CASE_INSENSITIVE); orderCheck.matcher(value).matches(); And
Here is an example I'm using: Pattern p = Pattern.compile(.*<img[^>]*src=\([^\]*), Pattern.CASE_INSENSITIVE); Matcher m =
I'm trying to create a summarizer in Java. I'm using the Stanford Log-linear Part-Of-Speech
i want to find whether a particular pattern exists in my text file or

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.