Need help with using regular expression in Java
- by richard
Hi,
I am trying to match pattern like '@(a-zA-Z0-9)+ " but not like 'abc@test'.
So this is what I tried:
Pattern MY_PATTERN
= Pattern.compile("\\s@(\\w)+\\s?");
String data = "[email protected] #gogasig @jytaz @tibuage";
Matcher m = MY_PATTERN.matcher(data);
StringBuffer sb = new StringBuffer();
boolean result = m.find();
while(result) {
System.out.println (" group " + m.group());
result = m.find();
}
But I can only see '@jytaz', but not @tibuage.
How can I fix my problem? Thank you.