Changeset 4ee6ae96


Ignore:
Timestamp:
Dec 22, 2017 1:52:59 PM (2 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
70b2dbe
Parents:
73796458
Message:

SusiMail?: Use pattern matcher

File:
1 edited

Legend:

Unmodified
Added
Removed
  • apps/susimail/src/src/i2p/susi/webmail/Mail.java

    r73796458 r4ee6ae96  
    4141import java.util.Locale;
    4242import java.util.TimeZone;
     43import java.util.regex.Pattern;
    4344
    4445import net.i2p.data.DataHelper;
     
    5354       
    5455        private static final String DATEFORMAT = "date.format";
    55        
    5656        private static final String unknown = "unknown";
     57        private static final String P1 = "^[^@< \t]+@[^> \t]+$";
     58        private static final String P2 = "^<[^@< \t]+@[^> \t]+>$";
     59        private static final Pattern PATTERN1 = Pattern.compile(P1);
     60        private static final Pattern PATTERN2 = Pattern.compile(P2);
    5761
    5862        private int size;
     
    217221
    218222                for( int i = 0; i < tokens.length; i++ ) {
    219                         if( tokens[i].matches( "^[^@< \t]+@[^> \t]+$" ) )
     223                        if (PATTERN1.matcher(tokens[i]).matches())
    220224                                return "<" + tokens[i] + ">";
    221                         if( tokens[i].matches( "^<[^@< \t]+@[^> \t]+>$" ) )
     225                        if (PATTERN2.matcher(tokens[i]).matches())
    222226                                return tokens[i];
    223227                }
Note: See TracChangeset for help on using the changeset viewer.