How Spammers Avoid the Gmail Spam Filter through Google Forms

Gmail is very effective at filtering spam emails but spammers seem to have figured out a new way to bypass the spam filters and send emails that land right in the user’s inbox. The emails are sent through Google Forms and because the messages originate from Google’s own email servers, they do not get caught in the spam filters.

Google Forms - Spam Emails

Here’s how spam emails are sent through Google Forms.

  1. A public form is created with Google Forms.
  2. The form creator uploads images for the various question fields and also adds links to spam websites in the form.
  3. Inside the Form settings, they turn on the option to “Collect Email Addresses” including the option to send “Response receipts” when a new form is submitted.

Google Form Email

Now the spammers can simply open the Google Form, fill in the recipient’s email address and hit the submit button.

Google Forms will automatically email a copy of the form response, including all the pictures and links contained in the original form, to the email address that was entered in the form.

Here’s a screenshot of one such email from Google Forms that easily tricked the spam filters.

Google Forms

How to Block Spam from Google Forms

If you would like to prevent spam emails from Google Forms from landing in your inbox, Gmail filters can help.

All pre-filled Google Forms emails have the sender’s email address as below:

forms-receipts-noreply@google.com

You can create a filter in Gmail that will automatically delete emails that have Google Forms as the sender.

Google Forms Filter

Alternatively, you may open the form link from the email and click the “Report Abuse” button to report the form to Google. That is not likely to be a very effective strategy though as spammers can always switch to a different Google account.

How to Learn Regular Expressions

Regular Expressions, or RegEx, are used for searching patterns in text. For instance, a RegEx like iP(hone|ad|od)s? will find mentions of any iOS device in a document. Knowledge of Regular Expressions is essential for programmers but they can be a great skill to have for non-developers as well - people who use Microsoft Word or spend hours inside Google Spreadsheets.

RegEx in Microsoft Word

Why Learn Regular Expressions?

Regular Expressions are extremely powerful, and no less intimidating, but even basic understanding of RegEx will save you time and make your everyday computing tasks easier.

For instance, you can quickly find & replace text that matches complex patterns in Word or Vim. You can easily extract phone numbers and emails in spreadsheet cells using regex formulas. If you are creating a form in Google Drive, RegEx can help you define validation rules for user input. You can use RegEx in Gmail and Google Analytics too.

How do you learn Regular Expressions? Or, if you are already familiar, how do you take your RegEx skills to the next level? You will obviously learn by doing but there are some excellent tools and learning resources on the Internet that will take make your journey to knowing Regular Expressions more pleasant.

The Best RegEx Tools & Resources

Lea Verou’s presentation will give you a good overview of what Regular Expressions are and what you can do with them. Jeffrey Friedl’s book - Mastering Regular Expressions - is still the best printed reference for RegEx newbies and masters. You can explore RegexOne, an interactive Codecademy-like online tutorial for learning RegEx or go here for learning the basics of pattern matching.

Highlighting all the non-English characters Highlighting all the non-English characters

RegExr is like a visual playground for Regular Expressions. You enter the text in one block and the RegEx in the other. As you edit the RegEx, the matching strings are highlighted in the input text. You can also hover over any character literal in the RegEx to know what it does. RegEx101 is a similar tool that also describes your RegEx in English as you write.

Regulex and RegExper are both open-source web apps that make it easy for you to understand and read Regular Expressions. You enter a RegEx and the tools will create a Railroad Diagram - for a string to match, it should be able to successfully move from left of the diagram all the way to the left along one of the available paths.

RegEx Visualizer

Windows users can download Expresso, a free program that will help beginners write both simple and complex regular expressions through a visual builder. Instead of coding the RegEx manually, you can select the components in a wizard. Reggy for Mac and RegEx Coach for Windows can also help you test regular expressions outside the browser.

Also see: How to Learn Coding

Once you understand the basics, head over to RegEx Golf or play this RegEx Crossword to test your skills. Like with everything else, you’ll only learn Regular Expressions by practicing and mere reading won’t be sufficient.

Find Who has Access to your Google Drive Files and Folders

The files and folders in your Google Drive are private by default until you decide to share them. You can share your documents with specific people or you can make them public and anyone on the Internet can view the shared files. Google Apps users have the option to share files and folders within the organization while restricting access to anyone outside the domain.

You can not only control who has access to your Google Drive files but can also assign the level of access they have on the shared files. You can set the access permissions to either view (read only) or edit (read & write). For instance, if you are to send a large file, you can upload the file to Google Drive and share it in view-mode with the recipient.

Who Can View or Edit your Drive Files

You may have a number of documents, spreadsheets and other files in your Google Drive that are accessible to other users. These users could be your contacts, someone within your Google Apps domain or some of the shared files could be public meaning they are available to anyone on the web who have the link (URL) to the file.

Would you like to know which files and folders in your Google Drive are shared with other users and what kind of access permissions they have on your files? Google Drive, unfortunately, doesn’t offer an easy option for you to figure out who you are sharing the files with either inside or outside your organization.

Meet Permissions Auditor for Google Drive, a new Google add-on that scans your entire Drive and then generates a comprehensive report revealing who has access to your shared files and what kind of permission they have on the files. If you have been collaborating with people for some time, the Drive Auditor is probably is the easiest way to find out what you’ve shared in Google Drive and sanitize it.

Here’s a sample audit report.

Google Drive - File Privacy Report

Google Drive - File Permissions Report

Getting started is easy. First, install the Google Drive Auditor add-on and authorize it. Internally, this is a Google Script that runs inside your Google Account, reads the files found in Google Drive and writes their access details in the spreadsheet. Not a single byte of data every leaves your Google Account.

Watch the video tutorial for a more detailed guide.

After the Drive Audit add-on is installed, go to the Add-ons menu inside the Google Spreadsheet, choose Drive Permissions Auditor and select Start Audit. It will open a sidebar where you need to specify a query and all matching files that match the query will be analyzed by the add-on.

Some sample Google Drive Search queries include:

  • “me” in owners and trashed = false (all files owned by except those in trash)
  • modifiedTime > ‘2016-01-01T12:00:00’ (file modified since Jan 2016 UTC)
  • mimeType = ‘application/vnd.google-apps.spreadsheet’ (scan the access permissions of only Google Spreadsheets in my Google Drive)

Once the audit is complete, the report will reveal detailed information of every file including:

  • When was a file created and last modified
  • What is the file size and MIME type (file extension)
  • Who is the owner of the file
  • Who has edit, view and comment permissions on the file
  • Where is the file located in Google Drive

You can click the File Name in the spreadsheet to directly open the corresponding file in Google Drive. Also, you can use the find function or even filters in Google Spreadsheets to display specific files that match a certain criteria. For instance, if you wish to know about all files that are public, you can apply a filter on the Access column in the spreadsheet.

The Drive Permissions Auditor add-on works for both Gmail and Google Apps accounts. If you are a domain administrator, you can install the Drive Audit add-on for all users in your domain through the Google Apps Marketplace.

The add-on is free and lets you audit up to 200 files in your Google Drive. If you have more files, please upgrade to the premium edition and analyze every single file and folder in your Google Drive.

Bonus tip: Did you know that you can set an auto-expiry date for your shared links in Google Drive. The shared link will automatically stop working after a certain date or time set by you.

Find Who has Access to your Google Drive Files and Folders

The files and folders in your Google Drive are private by default until you decide to share them. You can share your documents with specific people or you can make them public and anyone on the Internet can view the shared files. Google Apps users have the option to share files and folders within the organization while restricting access to anyone outside the domain.

You can not only control who has access to your Google Drive files but can also assign the level of access they have on the shared files. You can set the access permissions to either view (read only) or edit (read & write). For instance, if you are to send a large file, you can upload the file to Google Drive and share it in view-mode with the recipient.

Who Can View or Edit your Drive Files

You may have a number of documents, spreadsheets and other files in your Google Drive that are accessible to other users. These users could be your contacts, someone within your Google Apps domain or some of the shared files could be public meaning they are available to anyone on the web who have the link (URL) to the file.

Would you like to know which files and folders in your Google Drive are shared with other users and what kind of access permissions they have on your files? Google Drive, unfortunately, doesn’t offer an easy option for you to figure out who you are sharing the files with either inside or outside your organization.

Meet Permissions Auditor for Google Drive, a new Google add-on that scans your entire Drive and then generates a comprehensive report revealing who has access to your shared files and what kind of permission they have on the files. If you have been collaborating with people for some time, the Drive Auditor is probably is the easiest way to find out what you’ve shared in Google Drive and sanitize it.

Here’s a sample audit report.

Google Drive - File Privacy Report

Google Drive - File Permissions Report

Getting started is easy. First, install the Google Drive Auditor add-on and authorize it. Internally, this is a Google Script that runs inside your Google Account, reads the files found in Google Drive and writes their access details in the spreadsheet. Not a single byte of data every leaves your Google Account.

Watch the video tutorial for a more detailed guide.

After the Drive Audit add-on is installed, go to the Add-ons menu inside the Google Spreadsheet, choose Drive Permissions Auditor and select Start Audit. It will open a sidebar where you need to specify a query and all matching files that match the query will be analyzed by the add-on.

Some sample Google Drive Search queries include:

  • “me” in owners and trashed = false (all files owned by except those in trash)
  • modifiedTime > ‘2016-01-01T12:00:00’ (file modified since Jan 2016 UTC)
  • mimeType = ‘application/vnd.google-apps.spreadsheet’ (scan the access permissions of only Google Spreadsheets in my Google Drive)

Once the audit is complete, the report will reveal detailed information of every file including:

  • When was a file created and last modified
  • What is the file size and MIME type (file extension)
  • Who is the owner of the file
  • Who has edit, view and comment permissions on the file
  • Where is the file located in Google Drive

You can click the File Name in the spreadsheet to directly open the corresponding file in Google Drive. Also, you can use the find function or even filters in Google Spreadsheets to display specific files that match a certain criteria. For instance, if you wish to know about all files that are public, you can apply a filter on the Access column in the spreadsheet.

The Drive Permissions Auditor add-on works for both Gmail and Google Apps accounts. If you are a domain administrator, you can install the Drive Audit add-on for all users in your domain through the Google Apps Marketplace.

The add-on is free and lets you audit up to 200 files in your Google Drive. If you have more files, please upgrade to the premium edition and analyze every single file and folder in your Google Drive.

Bonus tip: Did you know that you can set an auto-expiry date for your shared links in Google Drive. The shared link will automatically stop working after a certain date or time set by you.

Learning Vim for Beginners

Vim, or Vi Improved, is a powerful text editor that lets you do almost everything using keyboard shortcuts. You can replace text in a document, move or delete lines, automate edit actions, and more, without ever reaching for the mouse. Vim is the favorite source code editor of programmers but there’s no reason why you cannot use this editor for writing documents or composing long emails.

Vim can be confusing for people who are used to working inside visual editors like Microsoft Word or Google Docs but spend some time with Vim and it will be difficult for you to go back. Entire books have been devoted to teaching Vim but if you can manage to learn the basic commands, you’ll find yourself more efficient and productive.

Vim Logo

How to Learn Vi

Here’s a list of online tutorials and other helpful resources to help you learn Vim.

1. OpenVim - An interactive tutorial for learning the basics of Vim. Switch to the Practice page to test your existing Vim skills.

2. Vim Adventures - An online puzzle game for learning and memorizing Vim commands. You play the character of a blinking cursor that has to navigate the maze with the letter keys. If you are stuck, you can always type :help for a hint.

3. Vim Genius - This a flashcard style game to help you learn the basics of Vim. There are dedicated lessons for learning the motion keys (h,j,k,l) and for mastering copy-paste in vim.

4. Learn to Love Vim - The Linux Voice magazine has put together a quick video tutorial to get you started with Vim.

5. Vim Basics - Derek Wyatt has produced a bunch of video tutorials (screencasts) around teaching Vim. A good resource for novice users who prefer learning Vim by watching than reading.

6. Learning Vim - Mike Coutermarsh covers getting up and running, and eventually productive with Vim.

7. Vim - Precision Editing - Drew Neil, author of the popular Practical Vim title and Vimcasts.org, walks you through Vim and how the text editor is optimized for mouseless operations.

8. Vim Tutorial - The official Vim documentation is excellent and includes a step-by-step tutorial. You can also access this tutorial inside the Vim program through the :vimtutor command.

9. Vim Cheat Sheet - Print this because you’ll need it later.

10. Vim Masterclass - This Udemy course will help you master all the concepts of Vim and how to ‘think’ in Vim.

If you spend a lot of time typing text, learning Vim will be totally worth the effort. I wrote this article inside Visual Studio Code with Vim key bindings.

How to Add QR Codes in Emails and Google Documents

With Document Studio, you can create employee badges, event tickets, school tags and other types of documents that contain QR Code images.

To get started, go to your source spreadsheet and create a column that will the QR Code. Give it a title, say QR Code Image, and add a formula QRCODE in the first empty cell of that column as shown below.

qrcode.png

This will add the QR Code image link to all the cells of your spreadsheet where the source cell is not empty.

Add QR Codes in Google Documents

Click anywhere in the Google document where you wish to insert the QR Code and add the variable field {{QR Code Image}} - the merge process will get the QR code image link from the source sheet and replace it with an image in the generated document.

google-document-qr-code.png

Add QR Codes in Google Sheets

To add QR Codes in Google Spreadsheet, we use the IMAGE function with the first parameter as the variable field that contains the QR Code image link inside double quotes.

=IMAGE("{{QR Code Image}}", 4, 100, 100)

Remember to merge a few adjacent cells else the QR code image won’t be visible in the generated document.

spreadsheet-qr-code.png

Add QR Codes in Google Slide Presentations

In the case of Google Slides, add a new text box and type the QR code variable field inside the text box surrounded by double curly braces.

You should also vertically align the text to the top of the enclosed box so that the entire QR code image is visible.

google-slide-qrcode.png

Add QR Codes in Email Notifications

To add QR Code images in your email templates, add the HTML <img> tag with source set to the variable field that contains the QR Code.

<img src="{{QR Code Image}}" alt="QR Code" />

email-qr-code.png

The Best Places to Find Free, High-Res Images for your Website

Good, high-quality images add visual interest to your website. Another reason why photos have become so important is because web pages that include good photos get better engagement when shared on social sites like Twitter and Facebook.

high quality photo

Download High Quality Images for Free

The web offers billions of photos that are just a Google search away. The images that are in public domain, or licensed under the Creative Commons license, can be used without any copyright issues.

The only problem is that Google may not always surface the best content that is free. Their algorithms, at least for image search, prefer pages from premium stock photography websites and the free listings thus lose out. If Google isn’t helping in your quest for images, here are some of the best websites where you may find high-quality photos for free.

1. unsplash.com (Unsplash) - This is my favorite website for downloading high-resolution photographs. Subscribe to the email newsletter and you’ll get 10 photos in your inbox every 10 days. All images are under the CC0 license meaning they are in public domain and you are free to use them in any way you like.

2. google.com (LIFE) - The Google images website hosts millions of historical photographs from the LIFE library. You can add source:life to any query in Google image search to find these images and they are free for personal, non-commercial use.

3. flickr.com (The British Library) - The national library of the UK has uploaded over a million vintage photographs and scanned images to Flickr that are now in pubic domain and they encourage re-use.

4. picjubmo.com (Picjumbo) - Here you’ll find exceptionally high-quality photos for your personal and commercial use. The pictures have been shot by the site owner himself and all he requests for in return is proper attribution.

5. pixabay.com (Pixabay) - All the images on Pixabay are available under the CC0 license and thus can be used anywhere. Like Flickr, there’s an option to browse photographs by camera model as well.

6. publicdomainarchive.com (Public Domain Archive) - This is an impressive online repository of public domain images that are neatly organized in categories. It contains only high quality photos though the collection is limited at this time.

7. commons.wikimedia.org (Wikimedia Commons) - The site hosts 21+ million images under some kind of free license or in the public domain. The images are arranged in categories or you can find images through search keywords.

8. superfamous.com (Super Famous) - Another great resource for finding high-res images for your websites and other design projects. The images are licensed under Creative Commons and require attribution.

old historical photos

9. nos.twnsnd.co (New Old Stock) - Here you will find a curated collection of vintage photographs from public archives that are free of any copyright restrictions. If you are trying to create a twitter feed like @HistoricalPics, this might be a good source for images.

10. freeimages.com (Stock Exchange) - This is one of the biggest repositories of free images and graphics that you can use for almost any purpose. You do however need to sign-in to download the images. The site, previously hosted on the schx.hu domain, is now part of Getty Images.

11. raumrot.com (Raumrot) - The site features beautiful, hi-res 300DPI stock photographs available for both personal and commercial use. The pictures are sorted by subject and available under Creative Commons.

Related: Protect your photos from Casual Copying

12. gettyimages.com (Getty Images) - If you are looking for professional images for your website but without the expensive license fee, Getty has something in store for you. You can embed pictures from Getty Images for free on your website though in future, the embeds may carry ads.

13. pdpics.com (Public Domain Photos) - The website contains thousands of royalty free images that can be used in both personal and commercial projects but with attribution. Unlike other sites that merely curate content, the images found here have been clicked by their in-house photographers.

14. imcreator.com (IM Free) - A curated collection of outstanding high-quality photos on all subjects that are also free for commercial use. The images have mostly been sourced from Flickr and require attribution.

15. photopin.com (Photo Pin) - Flickr is among the biggest repository of photographs on the web and Photo Pin helps you easily find photos on Flickr that are available under the Creative Commons license. You get the embed code as well so you don’t have to host the images on your own server.

16. kaboompics.com (Kaboom Pics) - Karolina Grabowska, a web designer from Poland, has uploaded 550+ high-resolution photos (240-300dpi ) that you can use for all kind of projects included commercial ones. The photos are arranged in categories and tags or you can use the search box to quickly find images on various subjects.

17. morguefile.com (Morgue File) - The site hosts 300,000+ free images and you are free to use them in both personal and commercial projects even without attribution. The image gallery has a built-in cropping tool and you can even hotlink the images from your website.

18. magdeleine.co (Magdeleine) - Hand-picked and free stock photos that you can search by subject, mood or even the dominant color. Some of the images are copyright free and you can do whatever you like with those photos.

Tip: How to avoid common photos

You may have found a great photo that is perfect for your project but there’s a probability that several other websites are using the same image. It will therefore help if you do a reverse image search using Google Images to estimate the relative popularity of that image on the Internet.

Also see: Sell your Instagram & Facebook Photos

The Best Websites to Learn Coding Online

The Learn to Code movement has picked up momentum worldwide and that is actually a good thing as even basic programming skills can have a major impact. If you can teach yourself how to write code, you gain a competitive edge over your peers, you can think more algorithmically and thus can tackle problems more efficiently.

Learn Programming

Don’t just download the latest app, help redesign it. Don’t just play on your phone, program it. — Obama.

There’s no reason why shouldn’t know the basics of coding. You can automate tasks, you can program your Excel sheets, improve workflows, you can extract data from websites and accomplish so much more with code. You may not be in the business of writing software programs but knowing the basics of coding will help you communicate more effectively with developers.

Gone are the days when you had to enroll in expensive computer training classes as now exist a plethora of web-based courses that will help you learn programming at your own pace in the comfort of your web browser.

The Best Sites to Learn Programming

If you are ready to take the plunge, here are some of the best websites that offer courses in a variety of programming languages for free. I have also added a list of companion ebooks that will give you a more in-depth understanding of the language and they don’t cost anything either.

Programming LanguageOnline Courses and Video ScreencastsDownload PDF Books (Read online for free)
JavaScriptCode Academy, Learn Street, Code Combat, Code AvengersEloquent JavaScript, JavaScript Guide, Speaking JS, JS The Right Way, Oh My JS, Canvassing
HTML & CSSCode Academy, Don’t Fear The Internet, Tutsplus, Learn Layout, A to Z CSS, Dash, Web Accessibility, The Hello World, Khan Academy, HTML5 from ScratchMozilla, Dive into HTML5, 20 Things I Learned, HTML Dog, HTML & CSS, HTML5 for Designers, DOM Enlightenment, HTML Canvas
jQueryCode Academy, Tutsplus, Code SchooljQuery Fundamentals, Learn jQuery
PythonCode Academy, Google, Learn Street, Python Tutor, IHeartPYPython for You and Me,  Dive into Python, Learn Python the Hard Way, Think Python, Python for Fun, Tango with Django, Django
Ruby & Ruby on RailsCode Academy, TryRubyCode Learn, Railscasts, Rubymonk, Learn StreetWhy’s (Poignant) Guide to Ruby, Learn Ruby the Hard Way, Learn to Program, Learn Rails by Example
PHPCode AcademyPHP Programming, Practical PHP
Also see: How to Learn Regular Expressions (RegEx)
Google Apps ScriptGetting Started, Office Hours, Google Scripts Examples, Learning Apps Script
WordPressTreehouse, WordPress TV
Linux & Shell ScriptingStanford.edu, Explain ShellConquer the Command Line
Node.jsNodetuts, Node SchoolThe Node Beginner Book, Mixu’s Node book, Node Up and Running, Mastering Node.js
Angular JSCode School, Egg Head, Learn AngularAngular JS Tutorial, Thinking Angular, Angular Tutorial, Getting Started (Adobe)
Also see:Learn Touch Typing & Code Faster
Git (version control)Code School, Git Immersion, GitHub Training, UdacityPro Git, Learn Git, Gists in Github
Objective-C (iOS & Mac)Code School, Stanford, iTunesU
Chrome Dev ToolsCode School, Dev Tools Secret, Chrome Dev Tools Tutorial, Udacity, Building Browser Apps
Go LanguageGolang.org, GopherCastsProgramming in Go, Go by Example, Learning Go, Building Web Apps with Go, Learning Go
JavaLearn Java, Coding Bat, Java Udemy, LearnerooProgramming in Java, Thinking in Java, O’Reilly Learning Java, Think Java, Java & CS, Java for Python Devs
Android App DevelopmentUdacity (Google Developers), Coursera, The New Boston, Google University, App Development Essentials, Code Learn, App Inventor (Visual)
D3 (data visualization)Data Visualization for the Web, Dashing D3, D3 Tips & Tricks
Also see:Learn VIM, the text editor for programmers
SQL (Databases)SQL Zoo, SQL @Stanford, Essential SQL, SQL for Nerds, Intro to SQL, SQL Bolt, PHP & MySQL
Everything ElseUdacity, edX.org, Coursera, Udemy$, Lynda$, Pluralsight$, Treehouse$, Open Consortium, One Month Rails$

Teaching Kids to Code

If there are kids in the family, you should download either Tynker (Android/iOS) or the Hopscotch app for iPad and they can learn the basics of programming through games and puzzles.

There’s also Scratch, an MIT project that allows kids to program their own stories and games visually. Scratch is available as a web app or you can download it on your Mac/Windows/Linux computer for offline use. Microsoft TouchDevelop, Blockly and Alice are some other web apps that will introduce the concepts of computer progamming to your children.

On a related note, the following chart from Google Trends shows the relative search popularity of various programming languages over the last 5 years. The interest in PHP has dipped over the years, JavaScript has more or less maintained its position while the popularity of Python & Node.js is on the rise.

Popularity of Programming Languages

Useful Regular Expressions for Validating Input in Google Forms

Your organization has a few vacant positions and you are planning to use Google Forms to prepare a pre-interview questionnaire for job applicants. You have created a form and it has all the standard fields where candidates can enter their name, email address, website URL, phone number, zip code and other essential details.

The form is ready for publishing online but before you make it live, how would you ensure that candidates have entered data in the correct format? And even if the format is proper, is the data itself valid? Can you add a CAPTCHA to Google forms to prevent spam bots? Can you include a profanity filter to block people from submitting entries that include obscene words?

When you are expecting dozens, or even hundreds, of responses in your Google Forms, it is always a good idea to have some rules in place and respondents data should be matched against these rules even before they submit the form. For instance, if your form is asking for a person’s year of birth, they should only be allowed to enter a number between 1900 and 2014.

Advanced data validation in Google Forms using RegEx (regular expressions) Advanced data validation in Google Forms using RegEx (regular expressions)

Regular Expressions in Google Forms

Google Forms makes it relatively easy to add such advanced date validation rules to individual fields through Regular Expressions (or regex or regexp). Think of them as search patterns and every character entered in a form field is matched against that pattern - the form can only be submitted if the patter and the user-input matches.

Let’s understand this with a real-world example.

Say your Google form expects the user to enter their year of birth. At the time of designing the form, expand the “Data Validation” section below the form field (see screenshot above) and choose Regular Expression from the drop-down. Next select “Matches” in the other drop-down and enter ^(19\d{2}|20[0-1]\d)$ in the input field. The field will now accept input value like 1920, 2010 but would reject other values that fall outside the range.

Regular Expressions for Common Form Fields

A regular expression may appear gibberish but they aren’t so difficult to read and understand if you can know the basic rules of the language. What you see here is a compilation of some useful regular expressions that can be used to validate common form fields like URLs, phone numbers, zip codes, dates, etc.

1. Postal Address - allow only alphanumeric characters, spaces and few other characters like comma, period and hash symbol in the form input field.

[a-zA-Z\d\s\-\,\#\.\+]+

2. ZIP Code - the regex allows ZIP codes in standard formats and it matches both US and Indian zip codes.

^\d{5,6}(?:[-\s]\d{4})?$

3. Date - accept date input in the mm/dd/yyyy or mm-dd-yyyy formats.

((0[1-9])|(1[0-2]))[\/-]((0[1-9])|(1[0-9])|(2[0-9])|(3[0-1]))[\/-](\d{4})

Also see: Get Google Form Data by Email

4. Email Address - the regex below should match most common email address formats, including Gmail aliases that accept the ”+” sign but there’s no perfect solution.

[a-zA-Z0-9_\.\+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-\.]+

5. URL (Web domain) - this is useful for fields that require the user to enter their website address and it even matches the upcoming TLDs like .directory or .restaurant. The other regex matches YouTube URL including those using the youtu.be domains.

https?\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,}
https?\:\/\/(www\.)?youtu(\.)?be(\.com)?\/.*(\?v=|\/v\/)?[a-zA-Z0-9_\-]+

6. Character Limit - the default text box in a Google form allows users to input any number of characters but you can impose a limit with the help of regular expression. Here we limit the input to 140 characters much like Twitter.

[\w]{1,140}

7. Phone Numbers - these are often a series of numbers preceded by an optional ”+” sign and the area code may be inside brackets.

\+?\(?\d{2,4}\)?[\d\s-]{3,}

8. Price (with decimal) - if a form field requires users to enter a price of an item in their own currency, this regex will help. Replace the $ sign with your own currency symbol.

\$?\d{1,3}(,?\d{3})*(\.\d{1,2})?

9. Complex Password - only accept a string that has 1 uppercase alphabet, 1 lowercase alphabet, 2 digits and 1 special character. Also the minimum allowed length is 8 characters.

(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9].*[0-9])(?=.*[^a-zA-Z0-9]).{8,}

10. CAPTCHA - Google forms do not offer CAPTCHAs but you can create one using regex. Here’s a simple captcha that requires users to answer a simple question - what is 2+2?

^(4|[Ff][Oo][Uu][Rr])$

Also see: Regular Expressions for Gmail Search

11. Word Limit - If you would like to limit the number of words that a user can type in the input field of a Google Form, there’s a regex for that as well. In this case, we only allow any input that has between 10 to 15 words:

^[-\w]+(?:\W+[-\w]+){9,14}\W*$

Useful Regular Expressions for Validating Input in Google Forms

Your organization has a few vacant positions and you are planning to use Google Forms to prepare a pre-interview questionnaire for job applicants. You have created a form and it has all the standard fields where candidates can enter their name, email address, website URL, phone number, zip code and other essential details.

The form is ready for publishing online but before you make it live, how would you ensure that candidates have entered data in the correct format? And even if the format is proper, is the data itself valid? Can you add a CAPTCHA to Google forms to prevent spam bots? Can you include a profanity filter to block people from submitting entries that include obscene words?

When you are expecting dozens, or even hundreds, of responses in your Google Forms, it is always a good idea to have some rules in place and respondents data should be matched against these rules even before they submit the form. For instance, if your form is asking for a person’s year of birth, they should only be allowed to enter a number between 1900 and 2014.

Advanced data validation in Google Forms using RegEx (regular expressions) Advanced data validation in Google Forms using RegEx (regular expressions)

Regular Expressions in Google Forms

Google Forms makes it relatively easy to add such advanced date validation rules to individual fields through Regular Expressions (or regex or regexp). Think of them as search patterns and every character entered in a form field is matched against that pattern - the form can only be submitted if the patter and the user-input matches.

Let’s understand this with a real-world example.

Say your Google form expects the user to enter their year of birth. At the time of designing the form, expand the “Data Validation” section below the form field (see screenshot above) and choose Regular Expression from the drop-down. Next select “Matches” in the other drop-down and enter ^(19\d{2}|20[0-1]\d)$ in the input field. The field will now accept input value like 1920, 2010 but would reject other values that fall outside the range.

Regular Expressions for Common Form Fields

A regular expression may appear gibberish but they aren’t so difficult to read and understand if you can know the basic rules of the language. What you see here is a compilation of some useful regular expressions that can be used to validate common form fields like URLs, phone numbers, zip codes, dates, etc.

1. Postal Address - allow only alphanumeric characters, spaces and few other characters like comma, period and hash symbol in the form input field.

[a-zA-Z\d\s\-\,\#\.\+]+

2. ZIP Code - the regex allows ZIP codes in standard formats and it matches both US and Indian zip codes.

^\d{5,6}(?:[-\s]\d{4})?$

3. Date - accept date input in the mm/dd/yyyy or mm-dd-yyyy formats.

((0[1-9])|(1[0-2]))[\/-]((0[1-9])|(1[0-9])|(2[0-9])|(3[0-1]))[\/-](\d{4})

Also see: Get Google Form Data by Email

4. Email Address - the regex below should match most common email address formats, including Gmail aliases that accept the ”+” sign but there’s no perfect solution.

[a-zA-Z0-9_\.\+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-\.]+

5. URL (Web domain) - this is useful for fields that require the user to enter their website address and it even matches the upcoming TLDs like .directory or .restaurant. The other regex matches YouTube URL including those using the youtu.be domains.

https?\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,}
https?\:\/\/(www\.)?youtu(\.)?be(\.com)?\/.*(\?v=|\/v\/)?[a-zA-Z0-9_\-]+

6. Character Limit - the default text box in a Google form allows users to input any number of characters but you can impose a limit with the help of regular expression. Here we limit the input to 140 characters much like Twitter.

[\w]{1,140}

7. Phone Numbers - these are often a series of numbers preceded by an optional ”+” sign and the area code may be inside brackets.

\+?\(?\d{2,4}\)?[\d\s-]{3,}

8. Price (with decimal) - if a form field requires users to enter a price of an item in their own currency, this regex will help. Replace the $ sign with your own currency symbol.

\$?\d{1,3}(,?\d{3})*(\.\d{1,2})?

9. Complex Password - only accept a string that has 1 uppercase alphabet, 1 lowercase alphabet, 2 digits and 1 special character. Also the minimum allowed length is 8 characters.

(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9].*[0-9])(?=.*[^a-zA-Z0-9]).{8,}

10. CAPTCHA - Google forms do not offer CAPTCHAs but you can create one using regex. Here’s a simple captcha that requires users to answer a simple question - what is 2+2?

^(4|[Ff][Oo][Uu][Rr])$

Also see: Regular Expressions for Gmail Search

11. Word Limit - If you would like to limit the number of words that a user can type in the input field of a Google Form, there’s a regex for that as well. In this case, we only allow any input that has between 10 to 15 words:

^[-\w]+(?:\W+[-\w]+){9,14}\W*$