Jump to content
Michael Stevens

Need help fixing script to search by email address

Recommended Posts

I apologize if this is in the wrong forum.

I'm using a search script and it won't work with email addresses.  I have found information about the @ being a wildcard, so it won't work when searching for emails.  I understand why, I just don't understand how to modify what I have to make it work.  Here is my script.  Any help would be appreciated.  Be nice, I'm learning.

I've attached a screen capture here.

Thanks for your anticipated help.

screen cap.jpg

Share this post


Link to post
Share on other sites

You need to escape the @ character. Either enter it as \@, or make your script do it for you by:

Set Field [ Students::Email ; Substitute ( Search::Search Field ; "@" ; "\@" ) ]

--
P.S. Next time please post your script as code, not as a picture.

Share this post


Link to post
Share on other sites

Or you could set indexing to "unicode" in the field definition (thanks to JFS for the reminder...)

This is especially helpful when such an email field is accessible in search mode for users...

Share this post


Link to post
Share on other sites
27 minutes ago, Lem Alpha said:

Or you could set indexing to "unicode" in the field definition (thanks to JFS for the reminder...)

This is especially helpful when such an email field is accessible in search mode for users...

I would avoid changing the field indexing. If you do that, then it also makes it case sensitive, which can be confusing to users as well.

Share this post


Link to post
Share on other sites

True. But I have seldom seen emails encoded with upper case, so I think the benefits of users being able to search for emails using @ are greater.
And just making this field an auto-entered calc Lower ( Self ) would prevent indexing upper case chars.

I was specifically speaking of users manually searching for emails, of course.

Share this post


Link to post
Share on other sites
47 minutes ago, Lem Alpha said:

Or you could set indexing to "unicode" in the field definition

That may have unintended consequences: for example, searching for a@b will also find "axb". IOW, @ is still a wild card.

Share this post


Link to post
Share on other sites

This is also a good remark.

In my case of making it easier for users to search for emails, it was never an issue because when someone puts in the @ it means they put in a complete address, so there shouldn't be any parasitic results.

But of course, for such a scripted search, it would not be bulletproof then.

Thanks for pointing out these caveats, both of you.

Share this post


Link to post
Share on other sites

If you really want an exact match, I have used this before:

"==" & Quote ( $email_search )

That specifies an exact match and takes care of quoting the search term.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×

Important Information

By using this site, you agree to our Terms of Use.