Java String Sub String substringBetween(String source, String strBegin, String strEnd)

Here you can find the source of substringBetween(String source, String strBegin, String strEnd)

Description

substring Between

License

Open Source License

Declaration

public static String substringBetween(String source, String strBegin, String strEnd) 

Method Source Code

//package com.java2s;
/* /*from   w  w  w .j  ava 2s  .  co m*/
 * @(#)StringUtil.java 1.0 2004-10-11
 *
 * Copyright 2005 UFIDA Software Co. Ltd. All rights reserved.
 * UFIDA PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

public class Main {

    public static String substringBetween(String source, String strBegin, String strEnd) {
        if (null == source)
            return null;
        int index = source.indexOf(strBegin);
        int indexEnd = source.indexOf(strEnd);
        if (index < 0)
            index = 0 - strBegin.length();
        if (indexEnd < 0)
            indexEnd = source.length();
        return source.substring(index + strBegin.length(), indexEnd);
    }
}

Related

  1. substringBetween(final String s, final String tag)
  2. substringBetween(final String str, final String startToken, final String endToken)
  3. substringBetween(String line, final String delimiterBefore, final String delimiterAfter)
  4. substringBetween(String s, String part1, String part2)
  5. substringBetween(String s, String part1, String part2)
  6. substringBetween(String str, String before, String after)
  7. substringBetween(String str, String open, String close)
  8. substringBetween(String str, String open, String close)
  9. substringBetween(String str, String open, String close)