<commit_before>package thx;

using StringTools;
using thx.Arrays;
import thx.Monoid;
import haxe.Utf8;

/** Alias of `StringTools`, included so mixins work with `using thx.Strings;` **/
typedef HaxeStringTools = StringTools;

/**
Extension methods for strings.
**/
class Strings {
/**
`after` searches for the first occurrance of `searchFor` and returns the text after that.

If `searchFor` is not found, an empty string is returned.
**/
  public static function after(value : String, searchFor : String) {
    var pos = value.indexOf(searchFor);
    if (pos < 0)
      return "";
    else
      return value.substring(pos + searchFor.length);
  }

  /**
  `afterLast` searches for the last occurrance of `searchFor` and returns the text after that.

  If `searchFor` is not found, an empty string is returned.
  **/
    public static function afterLast(value : String, searchFor : String) {
      var pos = value.lastIndexOf(searchFor);
      if (pos < 0)
        return "";
      else
        return value.substring(pos + searchFor.length);
    }

/**
`capitalize` returns a string with the first character convert to upper case.
**/
  inline public static function capitalize(s : String)
    return Utf8.sub(s, 0, 1).toUpperCase() + Utf8.sub(s, 1, Utf8.length(s) - 1);

/**
Capitalize the first letter of every word in `value`. If `whiteSpaceOnly` is set to `true`
the process is limited to whitespace separated words.
**/
  public static function capitalizeWords(value : String, ?whiteSpaceOnly = false) : String {
    if(whiteSpaceOnly) {
    #if (php && haxe_ver>=4.0)
    return php.Global.ucwords(value);
#elseif (php && haxe_ver<4.0)
      return untyped __call__("ucwords", value);
#else
      return UCWORDSWS.map(capitalize(value), upperMatch);
#end
    } else {
      return UCWORDS.map(capitalize(value), upperMatch);
    }
  }

/**<commit_msg>add before() and beforeLast() similar to after()/afterLast()<commit_after>package thx;

using StringTools;
using thx.Arrays;
import thx.Monoid;
import haxe.Utf8;

/** Alias of `StringTools`, included so mixins work with `using thx.Strings;` **/
typedef HaxeStringTools = StringTools;

/**
Extension methods for strings.
**/
class Strings {
/**
`after` searches for the first occurrance of `searchFor` and returns the text after that.

If `searchFor` is not found, an empty string is returned.
**/
  public static function after(value : String, searchFor : String) {
    var pos = value.indexOf(searchFor);
    if (pos < 0)
      return "";
    else
      return value.substring(pos + searchFor.length);
  }

  /**
  `afterLast` searches for the last occurrance of `searchFor` and returns the text after that.

  If `searchFor` is not found, an empty string is returned.
  **/
    public static function afterLast(value : String, searchFor : String) {
      var pos = value.lastIndexOf(searchFor);
      if (pos < 0)
        return "";
      else
        return value.substring(pos + searchFor.length);
    }

/**
`before` searches for the first occurrance of `searchFor` and returns the text before that.

If `searchFor` is not found, an empty string is returned.
**/
  public static function before(value : String, searchFor : String) {
    var pos = value.indexOf(searchFor);
    if (pos < 0)
      return "";
    else
      return value.substring(0, pos);
  }

  /**
  `beforeLast` searches for the last occurrance of `searchFor` and returns the text before that.

  If `searchFor` is not found, an empty string is returned.
  **/
    public static function beforeLast(value : String, searchFor : String) {
      var pos = value.lastIndexOf(searchFor);
      if (pos < 0)
        return "";
      else
        return value.substring(0, pos);
    }

/**
`capitalize` returns a string with the first character convert to upper case.
**/
  inline public static function capitalize(s : String)
    return Utf8.sub(s, 0, 1).toUpperCase() + Utf8.sub(s, 1, Utf8.length(s) - 1);

/**
Capitalize the first letter of every word in `value`. If `whiteSpaceOnly` is set to `true`
the process is limited to whitespace separated words.
**/
  public static function capitalizeWords(value : String, ?whiteSpaceOnly = false) : String {
    if(whiteSpaceOnly) {
    #if (php && haxe_ver>=4.0)
    return php.Global.ucwords(value);
#elseif (php && haxe_ver<4.0)
      return untyped __call__("ucwords", value);
#else
      return UCWORDSWS.map(capitalize(value), upperMatch);
#end
    } else {
      return UCWORDS.map(capitalize(value), upperMatch);
    }
  }

/**
{'fraction_non_alphanumeric': 0.1151797603195739, 'fraction_numerical': 0.007101642254771416, 'mean_word_length': 3.375728155339806, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6136301', 'n_tokens_mistral': 1430, 'n_tokens_neox': 1386, 'n_words': 474}