5792 } 5793 5794 static CharPredicate CIRangeU(int lower, int upper) { 5795 return ch -> { 5796 if (inRange(lower, ch, upper)) 5797 return true; 5798 int up = Character.toUpperCase(ch); 5799 return inRange(lower, up, upper) || 5800 inRange(lower, Character.toLowerCase(up), upper); 5801 }; 5802 } 5803 5804 /** 5805 * This must be the very first initializer. 5806 */ 5807 static final Node accept = new Node(); 5808 5809 static final Node lastAccept = new LastNode(); 5810 5811 /** 5812 * Creates a predicate which can be used to match a string. 5813 * 5814 * @return The predicate which can be used for matching on a string 5815 * @since 1.8 5816 */ 5817 public Predicate<String> asPredicate() { 5818 return s -> matcher(s).find(); 5819 } 5820 5821 /** 5822 * Creates a stream from the given input sequence around matches of this 5823 * pattern. 5824 * 5825 * <p> The stream returned by this method contains each substring of the 5826 * input sequence that is terminated by another subsequence that matches 5827 * this pattern or is terminated by the end of the input sequence. The 5828 * substrings in the stream are in the order in which they occur in the 5829 * input. Trailing empty strings will be discarded and not encountered in 5830 * the stream. 5831 * 5832 * <p> If this pattern does not match any subsequence of the input then 5833 * the resulting stream has just one element, namely the input sequence in 5834 * string form. 5835 * | 5792 } 5793 5794 static CharPredicate CIRangeU(int lower, int upper) { 5795 return ch -> { 5796 if (inRange(lower, ch, upper)) 5797 return true; 5798 int up = Character.toUpperCase(ch); 5799 return inRange(lower, up, upper) || 5800 inRange(lower, Character.toLowerCase(up), upper); 5801 }; 5802 } 5803 5804 /** 5805 * This must be the very first initializer. 5806 */ 5807 static final Node accept = new Node(); 5808 5809 static final Node lastAccept = new LastNode(); 5810 5811 /** 5812 * Creates a predicate that tests if for a given input string argument, an 5813 * input sequence, there exists a subsequence that matches this pattern. 5814 * 5815 * @apiNote 5816 * This method creates a predicate that behaves as if it creates a matcher from the input sequence 5817 * and then calls {@code find}, for example a predicate of the form: 5818 * <pre>{@code 5819 * s -> matcher(s).find(); 5820 * }</pre> 5821 * 5822 * @return The predicate which can be used for finding a match on a subsequence of a string 5823 * @since 1.8 5824 * @see Matcher#find 5825 */ 5826 public Predicate<String> asPredicate() { 5827 return s -> matcher(s).find(); 5828 } 5829 5830 /** 5831 * Creates a stream from the given input sequence around matches of this 5832 * pattern. 5833 * 5834 * <p> The stream returned by this method contains each substring of the 5835 * input sequence that is terminated by another subsequence that matches 5836 * this pattern or is terminated by the end of the input sequence. The 5837 * substrings in the stream are in the order in which they occur in the 5838 * input. Trailing empty strings will be discarded and not encountered in 5839 * the stream. 5840 * 5841 * <p> If this pattern does not match any subsequence of the input then 5842 * the resulting stream has just one element, namely the input sequence in 5843 * string form. 5844 * |