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> 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;
}

```
['https://Stackoverflow.com/questions/12207102', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1603861/']
It is preferable, yes, since JSON is defined to be unicode.

If you have more specific things that are causing you trouble you should share them, otherwise I'd recommend watching [Ned Batchelder's Intro](http://bit.ly/unipain) if you're just generally uncomfortable with Unicode (in Python in particular). I don't know what is causing this to be a nuisance to you, since I don't know what you're doing with this dict.
You should keep everything internal to python in unicode if there's any chance you will need it. Where python speaks to other programs, use `s.encode('UTF-8')` to make a regular string that you can write to a file or socket or whatever. Use `s.decode('UTF-8')` to convert a string from a file/socket back to unicode. (UTF-8 seems like a reasonable default, but use whatever your protocol specifies.)