Posted to tcl by avl at Fri Jun 16 20:59:50 GMT 2017view raw
- proc t srvurl {
- set validityRE {(?xi)
- ^
- # Path part (already must start with / character)
- (?: [-\w.~!$&'()*+,;=:@/] | %[0-9a-f][0-9a-f] )*
- # Query part (optional, permits ? characters)
- (?: \? (?: [-\w.~!$&'()*+,;=:@/?] | %[0-9a-f][0-9a-f] )* )?
- $
- }
- if {![regexp -- $validityRE $srvurl]} {
- # Provide a better error message in this error case
- if {[regexp {(?i)%(?![0-9a-f][0-9a-f])..} $srvurl bad]} {
- puts stdout "Yes!! That is it!!"
- }
- puts stdout error "No, try again. :("
- }
- }
- % t http://foo.bar/snafu?%##
- Yes!! That is it!!
- wrong # args: should be "puts ?-nonewline? ?channelId? string"
- % t /snafu?%##
- Yes!! That is it!!
- wrong # args: should be "puts ?-nonewline? ?channelId? string"
- % t ?%##
- Yes!! That is it!!
- wrong # args: should be "puts ?-nonewline? ?channelId? string"
- % t %##
- Yes!! That is it!!
- wrong # args: should be "puts ?-nonewline? ?channelId? string"