7 kyu

Hide password from jdbc url

466 of 943Javatlacati

Description:

We have to create a function that receives a connection string with password included and you have to mask the password i.e. change password by asterisks.

Preconditions:

  • non empty valid url
  • password always next to string section password=
  • assume password will not contain ampersand sign for sake of simplicity
  • to make it more real it has non ASCII characters
  • "password=" and "user" will occur only once

empty passwords are not validated but best solutions take empty passwords into account

Example:


input

jdbc:mysql://sdasdasdasd:szdasdasd:dfsdfsdfsdf/sdfsdfsdf?user=root&password=12345

output

jdbc:mysql://sdasdasdasd:szdasdasd:dfsdfsdfsdf/sdfsdfsdf?user=root&password=*****

Extra readings:

https://alvinalexander.com/java/jdbc-connection-string-mysql-postgresql-sqlserver

Strings
Regular Expressions
Fundamentals

Similar Kata:

Stats:

CreatedFeb 1, 2018
PublishedFeb 7, 2018
Warriors Trained1947
Total Skips91
Total Code Submissions8203
Total Times Completed943
JavaScript Completions466
CoffeeScript Completions11
Java Completions275
Kotlin Completions216
Total Stars34
% of votes with a positive feedback rating90% of 246
Total "Very Satisfied" Votes205
Total "Somewhat Satisfied" Votes33
Total "Not Satisfied" Votes8
Total Rank Assessments6
Average Assessed Rank
7 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • Javatlacati Avatar
  • asmgf Avatar
  • JohanWiltink Avatar
Ad