Gets the substring before a given pattern

@param string
original string
@param pattern
pattern to check
@return substring before the pattern
971639
public String substringBefore(String string, String pattern) {
		if (string == null || pattern == null) {
			return string;
		}
		int pos = string.indexOf(pattern);
		if (pos != -1) {
			return string.substring(0, pos);
		}
		return null;
	}
1280621
public static CharSequence matchesPattern(final CharSequence input, final String pattern, final String message) {
        return INSTANCE.matchesPattern(input, pattern, message);
    }
1152576
private static function getPattern(string $pattern)
    {
        $keywords = preg_split("/\\//", $pattern);
        $i = '0';
        $word = "";
        foreach ($keywords as $keyword) {
            $i++;
            if (preg_match("/:/i", $keyword)) {
                $word .= "([a-zA-Z0-9-._]+)";
            } else {
                $word .= $keyword;
            }
            if (count($keywords) != $i) {
                $word .= "/";
            }
        }

        return $word;
    }
1284176
final public function preQuery($pattern, $data = null)
    {
        $this->preQueries[] = array($pattern, $data);
        if ($this->connected) {
            $this->execPre();
        }
    }
687925
public static function matchesWildcardPattern($predicateString, $pattern) {

        // Only do a fuzzy match if at least a single * character found.
        if (is_numeric(strpos($pattern, "*"))) {
            $pattern = str_replace("\\*", "(.*)", preg_quote($pattern, "/"));
            $regex = "/" . $pattern . "/";
            return preg_match($regex, $predicateString) > 0;

        } else {
            return $predicateString == $pattern;
        }

    }
1281320
public static final String prefix(String pattern)
    {
        int idx = CharSequences.lastIndexOf(pattern, BeanHelper::separator);
        if (idx != -1)
        {
            return pattern.substring(0, idx);
        }
        else
        {
            return "";
        }
    }
1130044
public boolean startsWith(Text pattern) {
    	if (pattern == null) {
    		return false;
    	}
    	return this.subSequence(0, pattern.len).equals(pattern);
    }
1172877
public static SimonPattern create(String pattern) {
		if (pattern == null) {
			return null;
		}

		return createForType(pattern, Simon.class);
	}
165572
public static String before(String text, String before) {
        if (!text.contains(before)) {
            return null;
        }
        return text.substring(0, text.indexOf(before));
    }
1350415
function findNextSeparator(pattern) {
    if ('' == pattern) {
        // return empty string if pattern is empty or false (false which can be returned by substr)
        return '';
    }
    // first remove all placeholders from the pattern so we can find the next real static character
    pattern = pattern.replace(/\{\w+\}/g, '');

    return isset(pattern[0]) && (-1 != SEPARATORS.indexOf(pattern[0])) ? pattern[0] : '';
}
881581
public static String format(final LocalTime self, String pattern) {
        return self.format(DateTimeFormatter.ofPattern(pattern));
    }
447516
public function pattern($pattern = null)
        {
            if ($pattern === null) return $this->rulePattern;

            $this->rulePattern = $pattern;

            return $this;
        }
1209947
static List<String> parsePattern(String pattern) {
    List<String> parameters = new ArrayList<>(4);
    Matcher matcher = PARAM_REGEX.matcher(pattern);
    while (matcher.find()) {
      parameters.add(matcher.group(1));
    }
    return parameters;
  }
92614
public SortArgs get(String pattern) {

        LettuceAssert.notNull(pattern, "Pattern must not be null");

        if (get == null) {
            get = new ArrayList<>();
        }
        get.add(pattern);
        return this;
    }
1316751
private String matchPatternInBuffer(Pattern pattern) {
        matchValid = false;
        matcher.usePattern(pattern);
        matcher.region(position, buf.limit());
        if (matcher.lookingAt()) {
            if (matcher.hitEnd() && (!sourceClosed)) {
                // Get more input and try again
                needInput = true;
                return null;
            }
            position = matcher.end();
            return matcher.group();
        }

        if (sourceClosed)
            return null;

        // Read more to find pattern
        needInput = true;
        return null;
    }
324662
public static @Nonnull Predicate nameContains(final @Nonnull String pattern) {
        return new Predicate() {
            @Override
            public boolean isValid(@Nonnull ProcessThread<?, ?, ?> thread) {
                return thread.getName().contains(pattern);
            }
        };
    }
598421
@Override
    public final void applyPattern(String pattern)
    {

        if (hasRegistry())
        {
            super.applyPattern(pattern);
            toPattern = super.toPattern();
            return;
        }

        ArrayList<Format> foundFormats = new ArrayList<Format>();
        ArrayList<String> foundDescriptions = new ArrayList<String>();
        StringBuilder stripCustom = new StringBuilder(pattern.length());

        ParsePosition pos = new ParsePosition(0);
        char[] c = pattern.toCharArray();
        int fmtCount = 0;

        while (pos.getIndex() < pattern.length())
        {

            char charType = c[pos.getIndex()];

            if (QUOTE == charType)
            {

                appendQuotedString(pattern, pos, stripCustom, true);
                continue;

            }

            if (START_FE == charType)
            {

                fmtCount++;
                seekNonWs(pattern, pos);
                int start = pos.getIndex();
                int index = readArgumentIndex(pattern, next(pos));
                stripCustom.append(START_FE).append(index);
                seekNonWs(pattern, pos);
                Format format = null;
                String formatDescription = null;
                if (c[pos.getIndex()] == START_FMT)
                {
                    formatDescription = parseFormatDescription(pattern, next(pos));
                    format = getFormat(formatDescription);
                    if (format == null)
                    {
                        stripCustom.append(START_FMT).append(formatDescription);
                    }
                }
                foundFormats.add(format);
                foundDescriptions.add(format == null ? null : formatDescription);

                Preconditions.checkState(foundFormats.size() == fmtCount);
                Preconditions.checkState(foundDescriptions.size() == fmtCount);

                if (c[pos.getIndex()] != END_FE)
                {
                    throw new IllegalArgumentException("Unreadable format element at position " + start);
                }

            }

            //$FALL-THROUGH$
            stripCustom.append(c[pos.getIndex()]);
            next(pos);

        }

        super.applyPattern(stripCustom.toString());

        toPattern = insertFormats(super.toPattern(), foundDescriptions);

        if (containsElements(foundFormats))
        {
            Format[] origFormats = getFormats();
            // only loop over what we know we have, as MessageFormat on Java 1.3
            // seems to provide an extra format element:
            Iterator<Format> it = foundFormats.iterator();
            for (int i = 0; it.hasNext(); i++)
            {
                Format f = it.next();
                if (f != null)
                {
                    origFormats[i] = f;
                }
            }
            super.setFormats(origFormats);
        }

    }