Converts a given {@code Pattern} into a PERL style regular expression.

@param pattern
regular expression pattern
@return PERL style regular expression as string
12546
public static String convertPatternToPerlRegex(@Nonnull final Pattern pattern) {
		Check.notNull(pattern, "pattern");
		final String modifiers = Flag.convertToModifiers(Flag.parse(pattern.flags()));
		return String.format(PATTERN_TO_REGEX_TEMPLATE, pattern.pattern(), modifiers);
	}
1146627
public static Predicate<CharSequence> contains(Pattern pattern) {
		return t -> pattern.matcher(t).find();
	}
711347
private static String patternToString(@Nullable final Pattern pattern) {
		return pattern != null ? pattern.pattern() + " (flags: " + pattern.flags() + ")" : NO_PATTERN_PLACEHOLDER;
	}
939619
public static String format(final LocalDate self, String pattern) {
        return self.format(DateTimeFormatter.ofPattern(pattern));
    }
933689
private function pattern_to_regex($pattern)
    {
        if (substr($pattern, -1) == '/') {
            $pattern .= '**';
        }

        $regex = '|^';
        foreach (explode('/', $pattern) as $i => $piece) {
            if ($i > 0) {
                $regex .= preg_quote('/', '|');
            }

            if ('**' == $piece) {
                $regex .= '.*';
            } else {
                $regex .= str_replace(array('?', '*'), array('[^/]', '[^/]*'), $piece);
            }
        }
        $regex .= '$|';

        return $regex;
    }
186578
public static String format(final Date date, final String pattern) {
        return format(date, pattern, null, null);
    }
644297
public static boolean isValidRegex(final String pattern) {
        try {
            if (pattern != null) {
                Pattern.compile(pattern);
                return true;
            }
        } catch (final PatternSyntaxException exception) {
            LOGGER.debug("Pattern [{}] is not a valid regex.", pattern);
        }
        return false;
    }
592943
public static String format(final OffsetDateTime self, String pattern) {
        return self.format(DateTimeFormatter.ofPattern(pattern));
    }
46469
public static String format(Object o, String pattern) {
        if (null == o) return "";
        return format(null, o, pattern, null, null);
    }
415688
protected XmlSchemaPatternFacet createPatternFacet(final String pattern) {
        XmlSchemaPatternFacet xmlSchemaPatternFacet = new XmlSchemaPatternFacet();
        xmlSchemaPatternFacet.setValue(pattern);
        return xmlSchemaPatternFacet;
    }
663874
public static String format(final String pattern, final Locale locale, final Object... arguments) {
		MessageFormat format = new MessageFormat(pattern, locale);
		return format.format(arguments);
	}
252348
public static Date parse(String date, String pattern) {
		return DateTimeFormat.forPattern(pattern).parseDateTime(date).toDate();
	}
1198391
@Nonnull
  public DescribeCommand match(@Nullable String pattern) {
    if (!"*".equals(pattern)) {
      matchOption = Optional.ofNullable(pattern);
      log.info("--match = {}", matchOption.orElse(""));
    }
    return this;
  }
187184
public static String preProcessPattern(String pattern) {
		int index = pattern.indexOf('\\');
		if (index < 0) {
			return pattern;
		}

		StringBuilder sb = new StringBuilder();
		for (int pos = 0; pos < pattern.length();) {
			char ch = pattern.charAt(pos);
			if (ch != '\\') {
				sb.append(ch);
				pos++;
				continue;
			}
			if (pos + 1 >= pattern.length()) {
				// we'll end the pattern with a '\\' char
				sb.append(ch);
				break;
			}
			ch = pattern.charAt(++pos);
			switch (ch) {
				case 'b':
					sb.append('\b');
					pos++;
					break;
				case 'f':
					sb.append('\f');
					pos++;
					break;
				case 'n':
					sb.append('\n');
					pos++;
					break;
				case '0':
				case '1':
				case '2':
				case '3':
				case '4':
				case '5':
				case '6':
				case '7': {
					// 1-3 octal characters: \1 \01 or \017
					pos += radixCharsToChar(sb, pattern, pos, 3, 8);
					break;
				}
				case 'r':
					sb.append('\r');
					pos++;
					break;
				case 't':
					sb.append('\t');
					pos++;
					break;
				case 'x': {
					// 1-2 hex characters: \xD or \xD9
					int adjust = radixCharsToChar(sb, pattern, pos + 1, 2, 16);
					if (adjust > 0) {
						// adjust by 1 for the x
						pos += 1 + adjust;
					} else {
						sb.append(ch);
						pos++;
					}
					break;
				}
				case ' ':
				case '\\':
				default:
					sb.append(ch);
					pos++;
					break;
			}
		}
		return sb.toString();
	}
1324545
public static String formatDate(@NotNull String pattern, @NotNull Date date) {
		return FastDateFormat.getInstance(pattern).format(date);
	}
529175
public MarcField matchValue(Pattern pattern) {
        if (value != null && pattern.matcher(value).matches()) {
            return this;
        }
        for (Subfield subfield : subfields) {
            if (pattern.matcher(subfield.getValue()).matches()) {
                return this;
            }
        }
        return null;
    }
1283304
public static Expression regexpPosition(String expression, String pattern) {
        return regexpPosition(x(expression), pattern);
    }