Java String Sub String substringMatches(final String source, final String substring, final boolean checkBoundaries)

Here you can find the source of substringMatches(final String source, final String substring, final boolean checkBoundaries)

Description

substring Matches

License

Open Source License

Declaration

public static final boolean substringMatches(final String source, final String substring,
            final boolean checkBoundaries) 

Method Source Code

//package com.java2s;

public class Main {
    public static final boolean substringMatches(final String source, final String substring,
            final boolean checkBoundaries) {
        if (source == null) {
            return false;
        }//from  www  .j  a  v  a  2s.  co  m

        if (substring == null || substring.length() == 0) {
            return true;
        }

        int index = source.indexOf(substring);
        if (index == -1) {
            return false;
        }

        if (!checkBoundaries || index == 0) {
            return true;
        }

        return !Character.isLetterOrDigit(source.charAt(index - 1));
    }
}

Related

  1. substringInBetween(String name, String prefix, String delimiter)
  2. substringL(String s, int i, int len)
  3. substringLinesWithTokenOfEOL( String originalString, String stringToBeInserted)
  4. substringMatch(CharSequence str, int index, CharSequence substring)
  5. substringMatch(CharSequence str, int index, CharSequence substring)
  6. substringMore(String s, int maxlen)
  7. subStringNobit(String str, int toCount, String more)
  8. subStringNotEncode(String subject, int size)
  9. subStringRight(String str, int length)