Pure Programmer
Blue Matrix


Cluster Map

Project: Credit Card Mask

Write a function that takes a credit card number in the format "1234 5678 9012 3456" and returns a string with all but the last four digits replaced with an "X". Use a regular expression to match a group of four digits followed by a space and replace them with "XXXX ".

Output
$ rustc CreditCardMask.rs error[E0432]: unresolved import `regex` --> CreditCardMask.rs:8:5 | 8 | use regex::Regex; | ^^^^^ maybe a missing crate `regex`? | = help: consider adding `extern crate regex` to use the `regex` crate error[E0425]: cannot find function `replaceAll` in this scope --> CreditCardMask.rs:13:9 | 13 | return replaceAll(cardNumber,Regex::new(r"\\d{4,4} ").unwrap(),"XXXX "); | ^^^^^^^^^^ not found in this scope error: aborting due to 2 previous errors Some errors have detailed explanations: E0425, E0432. For more information about an error, try `rustc --explain E0425`.

Solution