fork download
  1. import java.util.*
  2.  
  3. fun main(args: Array<String>) {
  4. val singleLinePattern = "^(?!\\./)(?!.*/\$)(?!.*\\.\\./)[0-9A-Za-z!\\-_*'(). /]+\$"
  5. println(singleLinePattern)
  6.  
  7. println("----------")
  8.  
  9. val validPathPattern = buildString {
  10. append("^") // Start of the line
  11. append("(?!\\./)") // Negative lookahead to exclude "./"
  12. append("[0-9A-Za-z_*'(). /]+") // Character set allowing specified characters
  13. append("(?!/\$)") // Negative lookahead to exclude "/" at the end
  14. append("\$") // End of the line
  15. }.trimIndent()
  16. print(validPathPattern)
  17. }
Success #stdin #stdout 0.14s 42028KB
stdin
Standard input is empty
stdout
^(?!\./)(?!.*/$)(?!.*\.\./)[0-9A-Za-z!\-_*'(). /]+$
----------
^(?!\./)[0-9A-Za-z_*'(). /]+(?!/$)$