is string a Http Url using regular expression - Android java.util.regex

Android examples for java.util.regex:URL Pattern

Description

is string a Http Url using regular expression

Demo Code

import android.util.Log;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import java.util.Calendar;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main{
    public static boolean isHttpUrl(String input) {
        //if (!isNullOrEmpty(input)) {
            String regexExpression = "http://([\\w\\WW-]+\\.)+[\\w\\W-]+(/[\\w\\W- ./?%&=]*)?";
            if (input.matches(regexExpression)) {
                return true;
            }//from ww  w .  j av  a  2  s. c o m
        //}
        return false;
    }

}

Related Tutorials