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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:28:00+00:00 2026-05-27T01:28:00+00:00

How can I get Text t; Graph g; from // Co Text t; Graph

  • 0

How can I get

Text t;
Graph g;

from

// Co
Text t;
Graph g;
// Co

?

// Co\r?\n(.*)\r?\n// Co

works when there is one line, but does not work with multiple lines.

  • 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-27T01:28:01+00:00Added an answer on May 27, 2026 at 1:28 am

    By default, . matches any character except newlines (\n), but you can use the Pattern.DOTALL flag to make it match newlines as well. So, for example, instead of this:

    final Pattern pat = Pattern.compile("// Co\r?\n(.*)\r?\n// Co");
    

    you would use this:

    final Pattern pat = Pattern.compile("// Co\r?\n(.*)\r?\n// Co", Pattern.DOTALL);
    

    Equivalently, you can set the s flag inside the regex itself, using either of these styles:

    final Pattern pat = Pattern.compile("// Co\r?\n((?s).*)\r?\n// Co");
    final Pattern pat = Pattern.compile("// Co\r?\n(?s:(.*))\r?\n// Co");
    

    which lets you control exactly which part of the regex accepts a newline for .. (But I’d stick with the DOTALL approach unless you have a regex where . sometimes means the one thing, sometimes the other.)

    Edited to add: It seems very likely — but you’ll have to determine this for yourself, based on your use-case — that you need to use non-greedy quantification, .*?, rather than greedy quantification, .*.

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

Sidebar

Related Questions

How can I get the selected text (not the selected value) from a drop-down
How can I get the text value from an elements's child? Say I have
I can't seem to get the Facebook Graph API to work in IE7, IE8,
How can I get the text value of a segment in a UISegmentedControl?
I have a database which is in Access (you can get it link text
How can i get section cell text on custom cell button click. is this
How can I get an application to write debug text to the Event Log
How can I get the length of text entered in a textbox using jQuery?
I can't seem to get this text to align vertically. Can someone please tell
How can you get the height of the Text component that's been created dynamically

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.