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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:24:34+00:00 2026-06-13T05:24:34+00:00

I am getting a String from a server and I have to use a

  • 0

I am getting a String from a server and I have to use a regular expression to parse it.

I know how I would do it using String functions (String.split and the likes), but not with regexes, which is in the homework requirements.

The Strings look like this:

12345 <RECTANGLE> 100 200 300 400 </RECTANGLE>

I have to use a regex to make that String become:

12345 RECTANGLE 100 200 300 400

So basically, I have to remove all the following characters: “<“, “>” and “/”. I also have to remove the last word, so I guess I don’t even have to check for “/” since removing the last word would probably remove the slash as well.

Right now I have:

shapeString.replaceAll("[</>]", "");

And it removes the characters I don’t need, but I don’t know how to remove the last word.

  • 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-13T05:24:35+00:00Added an answer on June 13, 2026 at 5:24 am

    You can add

    str.replaceAll(" [^ ]+$", "")
    

    to remove the last word and the space preceding it.

    Here is a link to ideone with a running example.

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

Sidebar

Related Questions

I am getting the date string from the server as 2012-06-21 18:13:33 -04:00 What
I'm getting this json string info from the server : {members:[[sd2840d,Johny],[jkld341,Marry]]} So I store
I am getting JSON response from the server..Inside that JSON string i am having
I am getting JSON string from website. I have data which looks like this
I am using php and getting some utf8 string from Javascript. I try to
I am getting a response from server which I need to deserialize using protobuf.
im having trouble getting a string (containing a URL) from one activity to another.
So, I'm getting a bunch of string values from a JSON object and then
How can i get Image tag from html String. I am getting description like
The XML String I am getting from other application is converting & to &amp;

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.