1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/// Deorginalizes a `&str`
///
/// ```
///     use inflector::numbers::deordinalize::deordinalize;
///     let mock_string: &str = "0.1";
///     let expected_string: String = "0.1".to_owned();
///     let asserted_string: String = deordinalize(mock_string);
///     assert!(asserted_string == expected_string);
///
/// ```
/// ```
///     use inflector::numbers::deordinalize::deordinalize;
///     let mock_string: &str = "-1st";
///     let expected_string: String = "-1".to_owned();
///     let asserted_string: String = deordinalize(mock_string);
///     assert!(asserted_string == expected_string);
///
/// ```
/// ```
///     use inflector::numbers::deordinalize::deordinalize;
///     let mock_string: &str = "0th";
///     let expected_string: String = "0".to_owned();
///     let asserted_string: String = deordinalize(mock_string);
///     assert!(asserted_string == expected_string);
///
/// ```
/// ```
///     use inflector::numbers::deordinalize::deordinalize;
///     let mock_string: &str = "1st";
///     let expected_string: String = "1".to_owned();
///     let asserted_string: String = deordinalize(mock_string);
///     assert!(asserted_string == expected_string);
///
/// ```
/// ```
///     use inflector::numbers::deordinalize::deordinalize;
///     let mock_string: &str = "2nd";
///     let expected_string: String = "2".to_owned();
///     let asserted_string: String = deordinalize(mock_string);
///     assert!(asserted_string == expected_string);
///
/// ```
/// ```
///     use inflector::numbers::deordinalize::deordinalize;
///     let mock_string: &str = "3rd";
///     let expected_string: String = "3".to_owned();
///     let asserted_string: String = deordinalize(mock_string);
///     assert!(asserted_string == expected_string);
///
/// ```
/// ```
///     use inflector::numbers::deordinalize::deordinalize;
///     let mock_string: &str = "9th";
///     let expected_string: String = "9".to_owned();
///     let asserted_string: String = deordinalize(mock_string);
///     assert!(asserted_string == expected_string);
///
/// ```
/// ```
///     use inflector::numbers::deordinalize::deordinalize;
///     let mock_string: &str = "12th";
///     let expected_string: String = "12".to_owned();
///     let asserted_string: String = deordinalize(mock_string);
///     assert!(asserted_string == expected_string);
///
/// ```
/// ```
///     use inflector::numbers::deordinalize::deordinalize;
///     let mock_string: &str = "12000th";
///     let expected_string: String = "12000".to_owned();
///     let asserted_string: String = deordinalize(mock_string);
///     assert!(asserted_string == expected_string);
///
/// ```
/// ```
///     use inflector::numbers::deordinalize::deordinalize;
///     let mock_string: &str = "12001th";
///     let expected_string: String = "12001".to_owned();
///     let asserted_string: String = deordinalize(mock_string);
///     assert!(asserted_string == expected_string);
///
/// ```
/// ```
///     use inflector::numbers::deordinalize::deordinalize;
///     let mock_string: &str = "12002nd";
///     let expected_string: String = "12002".to_owned();
///     let asserted_string: String = deordinalize(mock_string);
///     assert!(asserted_string == expected_string);
///
/// ```
/// ```
///     use inflector::numbers::deordinalize::deordinalize;
///     let mock_string: &str = "12003rd";
///     let expected_string: String = "12003".to_owned();
///     let asserted_string: String = deordinalize(mock_string);
///     assert!(asserted_string == expected_string);
///
/// ```
/// ```
///     use inflector::numbers::deordinalize::deordinalize;
///     let mock_string: &str = "12004th";
///     let expected_string: String = "12004".to_owned();
///     let asserted_string: String = deordinalize(mock_string);
///     assert!(asserted_string == expected_string);
///
/// ```
pub fn deordinalize(non_ordinalized_string: &str) -> String {
    if non_ordinalized_string.contains('.') {
        non_ordinalized_string.to_owned()
    } else {
        non_ordinalized_string.trim_end_matches("st")
            .trim_end_matches("nd")
            .trim_end_matches("rd")
            .trim_end_matches("th")
            .to_owned()
    }
}