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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:07:27+00:00 2026-06-11T06:07:27+00:00

I am currently working on a University assignment, and have a (most likely simple)

  • 0

I am currently working on a University assignment, and have a (most likely simple) question regarding regex / regular expressions.

To summarize; this assignment is a simple RSS feed manager, which uses JSP and a RESTful web service.

I am currently working on a section of the assignment spec which requires me to be able to input XML feed data (e.g. <feeds><feed><name>FEED NAME</name><uri>http://FEEDuri/</uri></feed></feeds&gt; etc..) and from this data, extract the FEED NAME & FEEDuri via regex.

My lecturer has provided a base method for us to work off, and I think I have implemented it correctly within my RESTful web service, and now I am implementing error handling.

I have successfully implemented error handling for the case where there is no data input by user. My question is this: Based on the example method (below), is it possible to implement error handling for the case where the feed format input is incorrect

eg: &lt; fed> FEED NAME < /fiid> < uro>http://FEEDuri< /pro>The XML tags here are obviously incorrect.

Will regex ONLY pull the group from the String IF it lies between the defined values passed as the arguement to the compile method?

To supplement my question, here is the base method given to us to use (instead of an XML parser):

public static List<Feed> getFeedsFromXml(String xml) {
      Pattern feedPattern = Pattern.compile("<feed>\\s*<name>\\s*([^<]*)</name>\\s*<uri>\\s*([^<]*)</uri>\\s*</feed>");
      Matcher feedMatch = feedPattern.matcher(xml);

      while (feedMatch.find()) {
          String feedName = feedMatch.group(1);
          String feedURI = feedMatch.group(2);
          feeds.add(new Feed(feedName, feedURI));
      }

      return feeds;
}
  • 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-11T06:07:29+00:00Added an answer on June 11, 2026 at 6:07 am

    Yes, the regex will only match sections of the string that it, well, matches. If your regex contains "<feed>", it’s not going to go matching strings like "<fed>" or "<fiid>".

    If there are no matches of the regex in the input string, feedMatch.find() will simply return false the first time you call it, so nothing in the while loop will execute. This method will simply return an empty list, as it probably should.

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

Sidebar

Related Questions

I am currently working in a .Net project but from university I have also
I am currently working on a university project, using HTML5. I have been writing
I`m currently working out the design for simple graphic editor, who support trivial operations
My team and I are currently working on a university project. We were given
I'm currently working on a project for my university. One thing I need to
I am currently working on a research project for a University in which I
In short, I am currently working on a research problem for my university that
I am currently working on building a very simple site for an open source
I have been working for several months on a RoR project with fellows university
Currently i have a working PHP edit script, which allows users to edit ads

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.