package com.vesperin.utils;

/**
 * @author Huascar Sanchez
 */
public class Strings {
  private static final String SINGLE_SPACE  = " ";
  private static final String BLANK_SPACE   = "";

  private Strings(){}

  public static String singleSpace(){
    return SINGLE_SPACE;
  }

  public static String blankSpace(){
    return BLANK_SPACE;
  }

  // thx to http://stackoverflow.com/questions/2559759/#2560017
  public static String splitCamelCase(String content) {
    return content.replaceAll("(?<!(^|[A-Z]))(?=[A-Z])|(?<!^)(?=[A-Z][a-z])", SINGLE_SPACE);
  }

  public static String substringWithin(final String text, final String open, final String close) {
    if (text == null || open == null || close == null) {
      return text;
    }

    final int start = text.indexOf(open);
    if (start != -1) {
      final int end = text.indexOf(close, start + open.length());
      if (end != -1) {
        return text.substring(start, end + open.length());
      }
    }

    return text;
  }

}

@@ -730,19 +730,77 @@
 urn 
-text;%0A    %7D
+BLANK_SPACE;%0A    %7D%0A%0A    final String toChange = Expect.nonNull(text);
 %0A%0A  
@@ -816,27 +816,31 @@
 nt start = t
-ext
+oChange
 .indexOf(ope
@@ -889,19 +889,23 @@
  end = t
-ext
+oChange
 .indexOf
@@ -975,19 +975,23 @@
 return t
-ext
+oChange
 .substri
@@ -1049,19 +1049,61 @@
 return t
-ext
+oChange.equals(text) ? BLANK_SPACE : toChange
 ;%0A  %7D%0A%0A%7D

make sure we return nothing rather than the actual input