All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sendsafely.handlers.ParseLinksHandler Maven / Gradle / Ivy

package com.sendsafely.handlers;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ParseLinksHandler 
{	
	private final String REGEX = "(https:\\/\\/[a-zA-Z\\.-]+\\/receive\\/\\?[A-Za-z0-9&=\\-]+packageCode=[A-Za-z0-9\\-_]+#keyCode=[A-Za-z0-9\\-_]+)";
	
	public List parse(String text) {
		List links = new ArrayList();
		
		Pattern pattern = Pattern.compile(REGEX);
		Matcher matcher = pattern.matcher(text);
		while(matcher.find()) {
			String link = matcher.group(0);
			if(!links.contains(link)) {
				links.add(link);
			}
		}
		return links;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy