Java String Sub String substringBetween(String line, final String delimiterBefore, final String delimiterAfter)

Here you can find the source of substringBetween(String line, final String delimiterBefore, final String delimiterAfter)

Description

substring Between

License

Open Source License

Declaration

public static String substringBetween(String line, final String delimiterBefore, final String delimiterAfter) 

Method Source Code

//package com.java2s;
/* /* w w  w .  j a v a 2 s . c  o m*/
Copyright 2005-2018, Foundations of Success, Bethesda, Maryland
on behalf of the Conservation Measures Partnership ("CMP").
Material developed between 2005-2013 is jointly copyright by Beneficent Technology, Inc. ("The Benetech Initiative"), Palo Alto, California.
    
This file is part of Miradi
    
Miradi is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License version 3, 
as published by the Free Software Foundation.
    
Miradi is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
    
You should have received a copy of the GNU General Public License
along with Miradi.  If not, see <http://www.gnu.org/licenses/>. 
*/

public class Main {
    public static String substringBetween(String line, final String delimiterBefore, final String delimiterAfter) {
        final int indexAfterFirstFromChar = line.indexOf(delimiterBefore) + 1;
        final int firstIndexOfToChar = line.indexOf(delimiterAfter, indexAfterFirstFromChar);

        return line.substring(indexAfterFirstFromChar, firstIndexOfToChar);
    }
}

Related

  1. substringBeforeLast(String text, String separator)
  2. substringBeforeLastChar(String str, String separator)
  3. substringBeforeLastIgnoreCase(final String target, final String separator)
  4. substringBetween(final String s, final String tag)
  5. substringBetween(final String str, final String startToken, final String endToken)
  6. substringBetween(String s, String part1, String part2)
  7. substringBetween(String s, String part1, String part2)
  8. substringBetween(String source, String strBegin, String strEnd)
  9. substringBetween(String str, String before, String after)