You need a whole input match here.
System.out.println(test.matches("^(http|https|ftp)://.*$"));
Edit:(Based on @davidchambers’s comment)
System.out.println(test.matches("^(https?|ftp)://.*$"));
Related Contents:
- Java: splitting a comma-separated string but ignoring commas in quotes
- Use String.split() with multiple delimiters
- Create array of regex matches
- Using Regular Expressions to Extract a Value in Java
- Match multiline text using regular expression
- Java; String replace (using regular expressions)?
- How do I convert CamelCase into human-readable names in Java?
- Split string into array of character strings
- How to use regex in String.contains() method in Java
- Why does String.split need pipe delimiter to be escaped?
- A regex to match a substring that isn’t followed by a certain other substring
- Is Java RegEx case-insensitive?
- RegEx backreferences in IntelliJ
- Regex for splitting a string using space when not surrounded by single or double quotes
- Java regex capturing groups indexes
- How can I count the number of matches for a regex?
- How to extract numbers from a string and get an array of ints?
- What is the regex for “Any positive integer, excluding 0”
- Regular expression to validate username
- Get the index of a pattern in a string using regex
- Java regular expression OR operator
- List of all special characters that need to be escaped in a regex
- Raw Strings in Java – for regex in particular. Multiline strings
- How to split String with some separator but without removing that separator in Java? [duplicate]
- How can I remove punctuation from input text in Java?
- Find everything between two XML tags with RegEx
- How does {m}{n} (“exactly n times” twice) work?
- Splitting on comma outside quotes
- Regex date format validation on Java
- Range of valid character for a base 64 encoding
- What is the regex to extract all the emojis from a string?
- Regular Expression for matching parentheses
- How do I remove the non-numeric character from a string in java? [closed]
- Replace all double quotes within String
- Check if string ends with certain pattern
- How to get regex matched group values
- Regex for checking if a string is strictly alphanumeric
- java.util.regex.PatternSyntaxException: Dangling meta character ‘+’ near index 0 +
- Extracting pairs of words using String.split()
- How do I ignore case when using startsWith and endsWith in Java? [duplicate]
- How to check if a given Regex is valid?
- How to create a regex for accepting only alphanumeric characters? [duplicate]
- Regex to check string contains only Hex characters
- How to replace a plus character using Java’s String.replaceAll method
- regular expression to match one or two dots [duplicate]
- Backreferences Syntax in Replacement Strings (Why Dollar Sign?)
- Java doesn’t work with regex \s, says: invalid escape sequence
- Java code/library for generating slugs (for use in pretty URLs)
- Regular expression matching fully qualified class names
- String.replaceAll(regex) makes the same replacement twice