Posted to tcl by gwlester at Fri Jun 16 20:38:43 GMT 2017view raw

  1. set srvurl {}; # the "this_part_here" of: http://foo.bar/this_part_here
  2. set validityRE {(?xi)
  3. ^
  4. # Path part (already must start with / character)
  5. (?: [-\w.~!$&'()*+,;=:@/] | %[0-9a-f][0-9a-f] )*
  6. # Query part (optional, permits ? characters)
  7. (?: \? (?: [-\w.~!$&'()*+,;=:@/?] | %[0-9a-f][0-9a-f] )* )?
  8. $
  9. }
  10. if {![regexp -- $validityRE $srvurl]} {
  11. unset $token
  12. # Provide a better error message in this error case
  13. if {[regexp {(?i)%(?![0-9a-f][0-9a-f])..} $srvurl bad]} {
  14. puts stdout "Yes!! That is it!!"
  15. }
  16. puts stdout error "No, try again. :("
  17. }