Tcl Partial String Match

Tcl Partial String Match

Hoping a kind tcl guru can help me.

I have this string match, which works, to match an email address.

if { [string match "[email protected]" $emailFromAddress] } {
   set sendAutoReply 0

This works perfectly, however I want the string to ignore joe.blogs@ and only match on the thisdomain.com. The reasoning behind this, I don't want to auto reply to any one from a specific domain i.e. thisdomain.com and since that could be 1000's of email addresses (which I won't know) my thinking is to just match on the domain name.

Any thoughts on how best to do this, in a nice simple way?

1

1 Answer

Use a wildcard in the pattern instead of an explicit username?

if { [string match "*@thisdomain.com" $emailFromAddress] } {
   set sendAutoReply 0
}
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

David Miller
Author

David Miller

David Miller brings 15 years of experience in global economics, personal finance strategy, and market dynamics. He specializes in turning complex economic trends into actionable insights for everyday readers.