|
| 1 | +package com.bobocode.se; |
| 2 | + |
| 3 | +import com.bobocode.util.ExerciseNotCompletedException; |
| 4 | + |
| 5 | +import java.util.regex.Pattern; |
| 6 | + |
| 7 | +/** |
| 8 | + * {@link CrazyRegex} is an exercise class. Each method returns Pattern class which |
| 9 | + * should be created using regex expression. Every method that is not implemented yet |
| 10 | + * throws {@link ExerciseNotCompletedException} |
| 11 | + * TODO: remove exception and implement each method of this class using java.util.regex.Pattern |
| 12 | + */ |
| 13 | +public class CrazyRegex { |
| 14 | + |
| 15 | + /** |
| 16 | + * Create Pattern that accepts String with regex inside and can |
| 17 | + * find all words "Curiosity" in text |
| 18 | + * |
| 19 | + * @return Pattern with regex expression |
| 20 | + */ |
| 21 | + public Pattern findSpecificWord() { |
| 22 | + throw new ExerciseNotCompletedException(); |
| 23 | + } |
| 24 | + |
| 25 | + /** |
| 26 | + * Create Pattern that accepts String with regex inside and can |
| 27 | + * find first word in text |
| 28 | + * |
| 29 | + * @return Pattern with regex expression |
| 30 | + */ |
| 31 | + public Pattern findFirstWord() { |
| 32 | + throw new ExerciseNotCompletedException(); |
| 33 | + } |
| 34 | + |
| 35 | + /** |
| 36 | + * Create Pattern that accepts String with regex inside and can |
| 37 | + * find last word in text |
| 38 | + * |
| 39 | + * @return Pattern with regex expression |
| 40 | + */ |
| 41 | + public Pattern findLastWord() { |
| 42 | + throw new ExerciseNotCompletedException(); |
| 43 | + } |
| 44 | + |
| 45 | + /** |
| 46 | + * Create Pattern that accepts String with regex inside and can |
| 47 | + * find all numbers in text |
| 48 | + * |
| 49 | + * @return Pattern with regex expression |
| 50 | + */ |
| 51 | + public Pattern findAllNumbers() { |
| 52 | + throw new ExerciseNotCompletedException(); |
| 53 | + } |
| 54 | + |
| 55 | + /** |
| 56 | + * Create Pattern that accepts String with regex inside and can |
| 57 | + * can find all dates like: 1971-11-23 |
| 58 | + * |
| 59 | + * @return Pattern with regex expression |
| 60 | + */ |
| 61 | + public Pattern findDates() { |
| 62 | + throw new ExerciseNotCompletedException(); |
| 63 | + } |
| 64 | + |
| 65 | + /** |
| 66 | + * Create Pattern that accepts String with regex inside and can |
| 67 | + * different variations of word 'color'. We are looking for: |
| 68 | + * 'color', 'colour', 'colors', 'colours' |
| 69 | + * |
| 70 | + * @return Pattern with regex expression |
| 71 | + */ |
| 72 | + public Pattern findDifferentSpellingsOfColor() { |
| 73 | + throw new ExerciseNotCompletedException(); |
| 74 | + } |
| 75 | + |
| 76 | + /** |
| 77 | + * Create Pattern that accepts String with regex inside and can |
| 78 | + * can find all zip codes in text |
| 79 | + * |
| 80 | + * @return Pattern with regex expression |
| 81 | + */ |
| 82 | + public Pattern findZipCodes() { |
| 83 | + throw new ExerciseNotCompletedException(); |
| 84 | + } |
| 85 | + |
| 86 | + /** |
| 87 | + * Create Pattern that accepts String with regex inside and can |
| 88 | + * find different variations of word 'link', We are looking for: |
| 89 | + * 'lynk', 'link', 'l nk', 'l(nk' |
| 90 | + * |
| 91 | + * @return Pattern with regex expression |
| 92 | + */ |
| 93 | + public Pattern findDifferentSpellingsOfLink() { |
| 94 | + throw new ExerciseNotCompletedException(); |
| 95 | + } |
| 96 | + |
| 97 | + /** |
| 98 | + * Create Pattern that accepts String with regex inside and can |
| 99 | + * find phone number. For example: 555-555-5555 |
| 100 | + * |
| 101 | + * @return Pattern with regex expression |
| 102 | + */ |
| 103 | + public Pattern findSimplePhoneNumber() { |
| 104 | + throw new ExerciseNotCompletedException(); |
| 105 | + } |
| 106 | + |
| 107 | + /** |
| 108 | + * Create Pattern that accepts String with regex inside and can |
| 109 | + * can find numbers with following requirements: |
| 110 | + * - inside the number can be only digits from 0 to 5 |
| 111 | + * - length 3 |
| 112 | + * |
| 113 | + * @return Pattern with regex expression |
| 114 | + */ |
| 115 | + public Pattern findNumbersFromZeroToFiveWithLengthThree() { |
| 116 | + throw new ExerciseNotCompletedException(); |
| 117 | + } |
| 118 | + |
| 119 | + /** |
| 120 | + * Create Pattern that accepts String with regex inside and can |
| 121 | + * find all words in text that have length 5 |
| 122 | + * |
| 123 | + * @return Pattern with regex expression |
| 124 | + */ |
| 125 | + public Pattern findAllWordsWithFiveLength() { |
| 126 | + throw new ExerciseNotCompletedException(); |
| 127 | + } |
| 128 | + |
| 129 | + /** |
| 130 | + * Create Pattern that accepts String with regex inside and can |
| 131 | + * find words and numbers with following constraints: |
| 132 | + * - not shorter than two symbols |
| 133 | + * - not longer than three symbols |
| 134 | + * |
| 135 | + * @return Pattern with regex expression |
| 136 | + */ |
| 137 | + public Pattern findAllLettersAndDigitsWithLengthThree() { |
| 138 | + throw new ExerciseNotCompletedException(); |
| 139 | + } |
| 140 | + |
| 141 | + /** |
| 142 | + * Create Pattern that accepts String with regex inside and can |
| 143 | + * find all words that begin with capital letter |
| 144 | + * |
| 145 | + * @return Pattern with regex expression |
| 146 | + */ |
| 147 | + public Pattern findAllWordsWhichBeginWithCapitalLetter() { |
| 148 | + throw new ExerciseNotCompletedException(); |
| 149 | + } |
| 150 | + |
| 151 | + /** |
| 152 | + * Create Pattern that accepts String with regex inside and can |
| 153 | + * find only the following abbreviation: |
| 154 | + * - AK, AL, AR, AZ, CA, CO, CT, PR, PA, PD |
| 155 | + * |
| 156 | + * @return Pattern with regex expression |
| 157 | + */ |
| 158 | + public Pattern findAbbreviation() { |
| 159 | + throw new ExerciseNotCompletedException(); |
| 160 | + } |
| 161 | + |
| 162 | + /** |
| 163 | + * Create Pattern that accepts String with regex inside and can |
| 164 | + * find all open braces |
| 165 | + * |
| 166 | + * @return Pattern with regex expression |
| 167 | + */ |
| 168 | + public Pattern findAllOpenBraces() { |
| 169 | + throw new ExerciseNotCompletedException(); |
| 170 | + } |
| 171 | + |
| 172 | + /** |
| 173 | + * Create Pattern that accepts String with regex inside and can |
| 174 | + * find everything inside [] |
| 175 | + * |
| 176 | + * @return Pattern with regex expression |
| 177 | + */ |
| 178 | + public Pattern findOnlyResources() { |
| 179 | + throw new ExerciseNotCompletedException(); |
| 180 | + } |
| 181 | + |
| 182 | + /** |
| 183 | + * Create Pattern that accepts String with regex inside and can |
| 184 | + * find all http links inside () |
| 185 | + * |
| 186 | + * @return Pattern with regex expression |
| 187 | + */ |
| 188 | + public Pattern findOnlyLinksInNote() { |
| 189 | + throw new ExerciseNotCompletedException(); |
| 190 | + } |
| 191 | + |
| 192 | + /** |
| 193 | + * Create Pattern that accepts String with regex inside and can |
| 194 | + * all http links |
| 195 | + * |
| 196 | + * @return Pattern with regex expression |
| 197 | + */ |
| 198 | + public Pattern findOnlyLinksInJson() { |
| 199 | + throw new ExerciseNotCompletedException(); |
| 200 | + } |
| 201 | + |
| 202 | + /** |
| 203 | + * Create Pattern that accepts String with regex inside and can |
| 204 | + * find all .com, .net and .edu emails |
| 205 | + * |
| 206 | + * @return Pattern with regex expression |
| 207 | + */ |
| 208 | + public Pattern findAllEmails() { |
| 209 | + throw new ExerciseNotCompletedException(); |
| 210 | + } |
| 211 | + |
| 212 | + /** |
| 213 | + * Create Pattern that accepts String with regex inside and can |
| 214 | + * can find the following examples of phone numbers: |
| 215 | + * - 555-555-5555 |
| 216 | + * - 555.555.5555 |
| 217 | + * - (555)555-5555 |
| 218 | + * |
| 219 | + * @return Pattern with regex expression |
| 220 | + */ |
| 221 | + public Pattern findAllPatternsForPhoneNumbers() { |
| 222 | + throw new ExerciseNotCompletedException(); |
| 223 | + } |
| 224 | + |
| 225 | + /** |
| 226 | + * Create Pattern that accepts String with regex inside and can |
| 227 | + * find only duplicates |
| 228 | + * |
| 229 | + * @return Pattern with regex expression |
| 230 | + */ |
| 231 | + public Pattern findOnlyDuplicates() { |
| 232 | + throw new ExerciseNotCompletedException(); |
| 233 | + } |
| 234 | + |
| 235 | + /** |
| 236 | + * You have a text where all names recorded as first name, last name. |
| 237 | + * Create matcher and use method replaceAll to record that names as: |
| 238 | + * - last name first name |
| 239 | + * |
| 240 | + * @return String where all names recorded as last name first name |
| 241 | + */ |
| 242 | + public String replaceFirstAndLastNames(String names) { |
| 243 | + throw new ExerciseNotCompletedException(); |
| 244 | + } |
| 245 | + |
| 246 | + /** |
| 247 | + * You have a text with phone numbers. |
| 248 | + * Create matcher and use method replaceAll to replace last digits: |
| 249 | + * - 555-XXX-XXXX |
| 250 | + * |
| 251 | + * @return String where in all phone numbers last 7 digits replaced to X |
| 252 | + */ |
| 253 | + public String replaceLastSevenDigitsOfPhoneNumberToX(String phones) { |
| 254 | + throw new ExerciseNotCompletedException(); |
| 255 | + } |
| 256 | + |
| 257 | + /** |
| 258 | + * You have a text with resources and links to those resources: |
| 259 | + * - [Bobocode](https://www.bobocode.com) |
| 260 | + * Create matcher and use method replaceAll to get the following result: |
| 261 | + * - <a href="https://www.bobocode.com">Bobocode</a> |
| 262 | + * |
| 263 | + * @return String where all resources embraced in href |
| 264 | + */ |
| 265 | + public String insertLinksAndResourcesIntoHref(String links) { |
| 266 | + throw new ExerciseNotCompletedException(); |
| 267 | + } |
| 268 | +} |
0 commit comments