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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:06:52+00:00 2026-05-26T15:06:52+00:00

This is for an assignment. If anybody else who is doing this assignment finds

  • 0

This is for an assignment. If anybody else who is doing this assignment finds this code then please don’t copy it.

EDIT: Apologies, as this work is now copyable, please credit me and I will ask my professor more on what he thinks of the matter.

So I have some file which contains something like this

public Test();
  Code:
   Stack=1, Locals=1, Args_size=1
   0:   aload_0
   1:   invokespecial   #1; //Method java/lang/Object."<init>":()V
   4:   return
  LineNumberTable: 
   line 3: 0


public static void main(java.lang.String[]);
  Code:
   Stack=3, Locals=3, Args_size=1
   0:   new #2; //class java/util/Scanner
   3:   dup
   4:   getstatic   #3; //Field java/lang/System.in:Ljava/io/InputStream;
   7:   invokespecial   #4; //Method java/util/Scanner."<init>":(Ljava/io/InputStream;)V
   10:  astore_1
   11:  aload_1
   12:  invokevirtual   #5; //Method java/util/Scanner.nextLine:()Ljava/lang/String;
   15:  astore_2
   16:  getstatic   #6; //Field java/lang/System.out:Ljava/io/PrintStream;
   19:  aload_2
   20:  invokestatic    #7; //Method add_periods:(Ljava/lang/String;)Ljava/lang/String;
   23:  invokevirtual   #8; //Method java/io/PrintStream.println:(Ljava/lang/String;)V
   26:  return
  LineNumberTable: 
   line 6: 0
   line 8: 11
   line 9: 16
   line 10: 26

and I am trying to separate the output so that the first output will be the following.

public Test();
  Code:
   Stack=1, Locals=1, Args_size=1
   0:   aload_0
   1:   invokespecial   #1; //Method java/lang/Object."<init>":()V
   4:   return
  LineNumberTable: 
   line 3: 0

and the second output would be the second method. Assume that I can’t use split using double new line characters as delimiters due to the fact that some of the output not shown here will be grabbed that I would rather not grab.

I have a regular expression that looks like the following.

files.scan(/.*\)\;\n(.+\n)*/)

What the regular expression is trying to do is the following:
The first part of the regular expression .*\)\; is trying to match the method name and it works fine.
The second part is supposed to match every single line after it and stop until it sees a double new line character at which stage it fails due to there being a double new line character.
What it returns instead is the last line of every single method and I don’t know why.
The same regex in python as shown below gets the whole piece of code but this doesn’t

ANSWER=re.search(r'.*\);\n(.+\n)*', STRING)

Can anyone explain why it isn’t working?

As this is an assignment after all please don’t give code to solve the problem that I am trying to do. I appreciate that, 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-05-26T15:06:53+00:00Added an answer on May 26, 2026 at 3:06 pm

    The problem is that scan returns an array of only the group matches (the parenthesized parts of the regexp) if there are any groups. To avoid the parenthesized parts becoming a group you can modify your regexp to use (?:...) instead of (...). scanwill return an array of the whole matches.

    Or, you can hand over a block to scan which has access to the groups as well as to the whole match through the variables $1, $2, … and $&.

    See Ruby’s doc for scan.

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

Sidebar

Related Questions

This is uni assignment and I have already done some stuff. Please go to
I am doing this assignment, make a program that solves sudoku. I have a
I am doing this assignment and I am having trouble writing this method recursively.
I've been trying to do this assignment and for it to work I need
For this assignment I had to create my own string class. I initially wrote
I've been working on this assignment, where I need to read in records and
How to set entire HTML in MSHTML? I am trying using this assignment: (Document
I obviously do not 'grok' C++. On this programming assignment, I have hit a
This is about a school assignment so I'm trying to do things by the
this is for an assignment at school, where I need to determine the size

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.