[英]Regex, removing “<xxxxxxx>” from a string
我有這樣的字符串
"<xxxxxx125xxxx>
<yy2yy>2</yy2yy>
<yy3yy>3</yy3yy>
<yyhhhhyy>50</yyyyy>
<yyyyy>123</yyyyy>"
如何獲得類似以下的輸出:
2 3 50 123
好吧,我正在使用Android,但我認為這是全球正則表達式吧?
只需使用<[^>]+>
正則表達式即可。
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("<[^>]+>", ""));
}
輸出:
2
3
50
123
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.