java to validate instagram url using regular expression

Java programme to validate instagram url of profile using regular expression

Regular expression for instagram url

^(https\:\/\/)?(www\.)?(instagram\.com)\/.+$

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mycompany.mavenproject1;

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

/**
 *
 * @author ASUS
 */
public class Helloworld {
 private static String facebookurl="";
     private static boolean instagram(String url){
        Pattern p = Pattern.compile("^(https\\:\\/\\/)?(www\\.)?(instagram\\.com)\\/.+$");
        Matcher m=p.matcher(url);
        boolean matches = m.matches();
        return matches;
    }
   public static void main(String[] args){

       System.out.println("result of facebook url"+ facebook(facebookurl));
   } 
}

Leave a Comment