我想從字符串中找到<
和>
之間的詞。查找< and >與正則表達式之間的所有詞
例如:
String str=your mobile number is <A> and username is <B> thanks <C>;
我想從字符串A
,B
,C
得到。
我已經試過
import java.util.regex.*;
public class Main
{
public static void main (String[] args)
{
String example = your mobile number is <A> and username is <B> thanks <C>;
Matcher m = Pattern.compile("\\<([^)]+)\\>").matcher(example);
while(m.find()) {
System.out.println(m.group(1));
}
}
}
出了什麼問題我在做什麼?
你喜歡有一個與短程解決方案'<電話<'** ** 876-5432'>'或長響了'<'**我nymber是<876-5432**'>' – MaxZoom