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

The Archive Base Latest Questions

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

I have a really long in-memory string stored in a val response: String that

  • 0

I have a really long in-memory string stored in a val response: String that looks something like

HTTP/1.1 200 OK
Server: Apache
Other: headers

<response>
<xml>
—much much more XML—
</xml>
</response>
0

I want to extract the

<response>
…
</response>

part of the string. So far, I have this:

"<response>.*?</response>".r findFirstIn response

…but for some reason Scala returns None. I did figure out a way to do this with indices and the slice function, but there has to be a neat way with regex. Anyone know how?

  • 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-07T22:04:30+00:00Added an answer on June 7, 2026 at 10:04 pm

    First of all, it is probably a much better idea to use an XML parser when working with XML responses. It might look like an overkill at first, but as the project grows it is very likely that you’ll end up with having to parse more complicated XML documents, which will be much harder with regex than with a full-fledged XML parser.

    Anyway, this regex works:

    "(?s)<response>.*?</response>".r findFirstIn response
    

    (?s) sets the DOTALL flag.

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

Sidebar

Related Questions

I have a really long integration test that simulates a sequential process involving many
So I have a really long chain of methods, something similar to: return self.append_command(fbghasjfa).append_command(input_file_part).append_command(output_video_codec_part).append_command(output_resolution_part).append_command(output_video_bitrate_part).append_command(strict_part).append_command(output_audio_codec_part).append_command(output_number_of_audio_channels_part).append_command(output_audio_bitrate_part).append_command(output_file_part).__finalized
I have this case <WrapPanel> <CheckBox>Really long name</CheckBox> <CheckBox>Short</CheckBox> <CheckBox>Longer again</CheckBox> <CheckBox>Foo</CheckBox> <Slider MinWidth=200
Currently I have UITableViewCell's that hold sometimes really long text (up to 50,000 pixels
I have a struct like this: typedef struct string { unsigned long length; unsigned
I have a really long port map where I want to replace a bunch
I have a block of text which occasionally has a really long word/web address
I have a rather long switch-case statement. Some of the cases are really short
I have a really long collection with 10k items, and when running a toString()
I have a bunch of classes that i have to tweak for improved memory

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.