java - Finding Upper Case in String Array and extracting it out -
i have array input email id in reverse order along data:
moc.oohay@abc.pqrqwertysddd moc.oohay@ab.jklasddbfn moc.oohay@xz.jkgposddbfn
i want output come as
moc.oohay@abc.pqr moc.oohay@ab.jkl moc.oohay@xz.jkg
how should filter string since there no pattern?
there pattern, , upper case character followed either upper case letter, period or else @
character.
translated, become this:
string[] input = new string[]{"moc.oohay@abc.pqrqwertysddd","moc.oohay@ab.jklasddbfn" , "moc.oohay@xz.jkgposddbfn"}; pattern p = pattern.compile("([a-z.]+@[a-z.]+)"); for(string string : input) { matcher matcher = p.matcher(string); if(matcher.find()) system.out.println(matcher.group(1)); }
yields:
moc.oohay@abc.pqr moc.oohay@ab.jkl moc.oohay@xz.jkg
Comments
Post a Comment