pike.git / lib / modules / String.pmod

version» Context lines:

pike.git/lib/modules/String.pmod:1:   #pike __REAL_VERSION__      #define BEGIN 32         constant Buffer = __builtin.Buffer;    - //! @decl string count(string haystack, string needle) - //! - //! This function counts the number of times the @[needle] - //! can be found in @[haystack]. - //! - //! @note - //! Intersections between needles are not counted, ie - //! @tt{count("....","..")@} is @tt{2@}. - //! +    constant count=__builtin.string_count; -  - //! @decl int width(string s) - //! - //! Returns the width in bits (8, 16 or 32) of the widest character - //! in @[s]. - //! +    constant width=__builtin.string_width; -  + constant trim_whites = __builtin.string_trim_whites; + constant trim_all_whites = __builtin.string_trim_all_whites;      /*    * Implode an array of strings to an english 'list'    * ie. ({"foo","bar","gazonk"}) becomes "foo, bar and gazonk"    */      //! This function implodes a list of words to a readable string.   //! If the separator is omitted, the default is <tt>"and"</tt>.   //! If the words are numbers they are converted to strings first.   //!
pike.git/lib/modules/String.pmod:222:    fuzz = 100;    } else {    fuzz = low_fuzzymatch(a, b);    fuzz += low_fuzzymatch(b, a);    fuzz = fuzz*100/(strlen(a)+strlen(b));    }       return fuzz;   }    - //! Trim leading and trailing spaces and tabs from the string @[s]. - //! - constant trim_whites = __builtin.string_trim_whites; -  - //! Trim leading and trailing white spaces characters (@tt{" \t\r\n"@}) from - //! the string @[s]. - //! - constant trim_all_whites = __builtin.string_trim_all_whites; -  +    //! Returns the soundex value of @[word] according to   //! the original Soundex algorithm, patented by Margaret O┬┤Dell   //! and Robert C. Russel in 1918. The method is based on the phonetic   //! classification of sounds by how they are made.   string soundex(string word) {    word = upper_case(word);    string first = word[0..0];    word = word[1..] - "A" - "E" - "H" - "I" - "O" - "U" - "W" - "Y";    word = replace(word, ([ "B":"1", "F":"1", "P":"1", "V":"1",    "C":"2", "G":"2", "J":"2", "K":"2",    "Q":"2", "S":"2", "X":"2", "Z":"2",    "D":"3", "T":"3",    "L":"4",    "M":"5", "N":"5",    "R":"6" ]) );    word = replace(word, ({"11", "22", "33", "44", "55", "66" }),    ({"", "", "", "", "", "", }));    word+="000";    return first + word[..2];   }