private static void validateTags ( String [ ] tagList , ArrayList < String > validList , ArrayList < String > invalidList ) { for ( String tag : tagList ) { tag = tag . trim ( ) ; if ( tag . contains ( "\\" ) || tag . contains ( " " ) || tag . contains ( "\n" ) || tag . contains ( "-" ) || tag . equals ( "" ) ) { invalidList . add ( tag ) ; } else { validList . add ( tag ) ; } } }
Filter out tags with escaping characters and invalid characters restrict to only alphabetical and numeric characters