I am trying to write a regular expression for somethin like
s1 = I am at Boston at Dowtown
s2 = I am at Miami
I am interested in the words after at eg: Boston, Downtown, Miami
I have not been successful in creating a regex for that. Somethin like
> .*? (at \w+)+.*
gives just Boston in s1 (Downtown is missed). it just matches the first "at" Any suggestions
Try this
at\s+(\w+)
The complete code snippet would be
Pattern myPattern = Pattern.compile("at\\s+(\\w+)", Pattern.DOTALL, Pattern.CASE_INSENSITIVE);
Matcher m = myPattern.matcher(yourString);
while(m.find()) {
String word = m.group(1);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With