0

I have a String like this

"<xxxxxx125xxxx>

<yy2yy>2</yy2yy>
<yy3yy>3</yy3yy>
<yyhhhhyy>50</yyyyy>
<yyyyy>123</yyyyy>"

How can I have an output like:

2 3 50 123

Well, i'm using Android, but I think that it's a global regex right?

Douglas Fornaro
  • 2,017
  • 2
  • 22
  • 30
  • possible duplicate of [How to remove HTML tag in Java](http://stackoverflow.com/questions/1699313/how-to-remove-html-tag-in-java) – donfuxx May 03 '14 at 17:52
  • Try `>\d+<` and remove `>` and `<` – Braj May 03 '14 at 17:52
  • Are you trying to reinvent `xml` or `html` parser? If yes then before you go any farther consider checking already created ones like Jsoup which seems to do exactly what you want: `String data = Jsoup.parse(data).text()` – Pshemo May 03 '14 at 17:52
  • I'm trying to get the data inside a table html tags. The tags can vary inside '<' and '>' – Douglas Fornaro May 03 '14 at 17:57

1 Answers1

0

Simply use <[^>]+> regex.

    String[] string = new String[] { "<yy2yy>2</yy2yy>", "<yy3yy>3</yy3yy>",
            "<yyhhhhyy>50</yyyyy>", "<yyyyy>123</yyyyy>" };

    for (String s : string) {
        System.out.println(s.replaceAll("<[^>]+>", ""));
    }

output:

2
3
50
123
Braj
  • 46,415
  • 5
  • 60
  • 76