Im trying to figure out how i can remove certain characters in an email address before the domain name using nothing but a simple regex and replaceAll in Java.
In email addresses,
- Need to remove any number of .before@<domain name>
- Also remove anything between +up to@but not including@. For instance injoebloggs+123@domain.comshould bejoebloggs@domain.com.
So far I have,
class Main {
  public static void main(String[] args) {
    String matchingRegex = "(\\.|(\\+.*(?=@)))";
    System.out.println("joe.bloggs+123@gmail.com".replaceAll(matchingRegex, ""));
  }
}
which replaces everything including the domain name.
joebloggs@gmailcom
What i really need is joebloggs@gmail.com.
Can this be achieved with regex alone ?
 
     
     
     
     
    