Java String Chop ChopAllLf(String this_string, String chomp_off)

Here you can find the source of ChopAllLf(String this_string, String chomp_off)

Description

Chop All Lf

License

Open Source License

Declaration

static public String ChopAllLf(String this_string, String chomp_off) 

Method Source Code

//package com.java2s;
//   Licensed under the Apache License, Version 2.0 (the "License"); you may

public class Main {
    static public String ChopAllLf(String this_string, String chomp_off) {
        if (!this_string.contains(chomp_off))
            return this_string;
        return ChopLf(this_string, chomp_off, SeekRt(this_string, chomp_off.charAt(0)) + this_string.length() + 1);
    }//from   w w  w.j  a v a 2 s  .  c o m

    static public String ChopLf(String this_string, String chomp_off) {
        if (!this_string.contains(chomp_off))
            return this_string;
        return this_string.substring(SeekLf(this_string, chomp_off.charAt(0)) + 1, this_string.length());
    }

    static public String ChopLf(String this_string, String chomp_off, Integer times) {
        if (times == 1)
            return ChopLf(this_string, chomp_off);
        return ChopLf(this_string, chomp_off, times - 1);
    }

    static private int SeekRt(String this_string, char c) {
        for (int i = -1; i + this_string.length() != 0; i--) {
            if (this_string.charAt(i) == c)
                return i;
        }
        return -1;
    }

    static private int SeekLf(String this_string, char c) {
        for (int i = 0; i < this_string.length(); i++) {
            if (this_string.charAt(i) == c)
                return i;
        }
        return -1;
    }
}

Related

  1. chop(String value, int size)
  2. chop(String x)
  3. chop(String[] arr, int pos)
  4. chop(StringBuffer buffer, int chars)
  5. chopAccelerator(final String title)
  6. ChopAllRt(String this_string, String chomp_off)
  7. chopBraces(String s)
  8. chopCommentFromArgs(String[] args)
  9. chopExt(String orig)