7 kyu

Hide password from jdbc url

459 of 929Javatlacati

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

Stats:

CreatedFeb 1, 2018
PublishedFeb 7, 2018
Warriors Trained1917
Total Skips90
Total Code Submissions8133
Total Times Completed929
JavaScript Completions459
CoffeeScript Completions10
Java Completions270
Kotlin Completions213
Total Stars34
% of votes with a positive feedback rating90% of 245
Total "Very Satisfied" Votes205
Total "Somewhat Satisfied" Votes33
Total "Not Satisfied" Votes7
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