Here you can find the source of isUrl(String text)
Parameter | Description |
---|---|
text | the string to test |
public static boolean isUrl(String text)
//package com.java2s; /*/*from ww w .j a v a 2 s . c o m*/ * This file is part of dependency-check-core. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Copyright (c) 2013 Jeremy Long. All Rights Reserved. */ import java.util.regex.Pattern; public class Main { /** * A regular expression to test if a string is a URL. */ private static final Pattern IS_URL_TEST = Pattern.compile("^(ht|f)tps?://.*", Pattern.CASE_INSENSITIVE); /** * Tests if the given text is url. * * @param text the string to test * @return returns true if the text is a url, otherwise false */ public static boolean isUrl(String text) { return IS_URL_TEST.matcher(text).matches(); } }