Skip to content
Studio 3T - The professional GUI, IDE and client for MongoDB
  • Tools
    • Aggregation Editor
    • IntelliShell
    • Visual Query Builder
    • Export Wizard
    • Import Wizard
    • Query Code
    • SQL Query
    • Connect
    • Schema Explorer
    • Compare
    • SQL ⇔ MongoDB Migration
    • Data Masking
    • Task Scheduler
    • Reschema
    • AI Helper
    • Team Sharing
    • Index Manager
    • More Tools and Features
  • Solutions
  • Resources
    • Knowledge Base
    • MongoDB Tutorials & Courses
    • Tool/Feature Documentation
    • Blog
    • Community
    • Testimonials
    • Whitepapers
    • Reports
  • Contact us
    • Contact
    • Sales Support
    • Feedback and Support
    • Careers
    • About Us
  • Store
    • Buy Now
    • Preferred Resellers
    • Team Pricing
  • Download
  • My 3T
search

The Value of a Regular Expression: #Studio3T_AMA

Posted on: 15/06/2022 by Dj Walker-Morgan

Q: I was using Value Search in Studio 3T, searching for “test” and I noticed the Regular Expression checkbox on the search window. Checking it made no difference to the results of my searches so what does it actually do?

Value Search is a recently introduced Studio 3T feature which allows you to search all the field values, no matter how embedded, in an entire collection, database or server.

Welcome to Studio 3T’s Ask Manatees Anything, where we answer your Studio 3T and MongoDB questions.

A: The reason you aren’t seeing any difference in your search results is because your simple string matches the same way whether or not you have regular expressions on or off. 

Where regular expressions come into their own is where you want to be more or less precise through the use of “special” characters.

If you think of wildcards, like the * in filenames, where a character takes on a special meaning (in this case to match any part of a filename), then you can think of Regular Expressions as that, but on steroids. And by that we mean it’s a super powerful way of matching strings, not just filenames, and they are supported in many many tools.

There are entire books about regular expressions, so we’ll just introduce some super useful characters you can use.

Anchoring your regular expression match

If you are looking for the word “test” only when it appears at the start of a field, prefix text with the ^ character to anchor your match to the start of any field like so: 

^test

Regular Expression in Value Search anchored to start of field

If you want your match to only happen at the end of a field, append a $ to anchor the match with the end, like this:

test$

Regular Expression in Value Search anchored to end of field

Regular expressions for anything

Regular expressions have their own version of a wildcard. Specifically the dot/full stop character, which says “match any character”. So if you wanted to match text, tent, and test you would search for:

te.t

Regular Expression with an any character match in Value Search

You do see regular expressions with the * character in them, but this isn’t a wildcard as used in file-name matching. It says “match with zero or more of the preceding character”, so if you used:

te*t

then you might see something like this:

Regular Expression with a * one or more character match - matching https:// in Value Search

What’s happened here? Well,  the * says zero or more, and while this match would match with:

tet

teet

teeeeet

teeeeeeeeeet

It will also match with tt which we find in a URL’s https:// opening as there is zero e between the two t. This can catch people out with some unexpected matches. If you want to be sure there’s one or more occurrences of your letter, use +.

Matching with te+t would match everything but tt.

Another thing to remember, if what you are searching for with a regular expression contains one of the special characters (and there are more of them) you’ll need to escape them by preceding each with a backslash. For example, searching for \.$ will find values which end with a full stop.

Bringing them together

Finally, on this brief tour of regular expressions for value searchers, you can bring all these special characters together. You can use the . with + and * to say one/none or more of any character. And you can anchor that match to the start or end of a field’s values.

^t.+t

Matching nearly the whole like of text with a Regular Expression for lines that start with t and have another t later on

Pro-tip: In Value search, if a field’s value is bigger than the table column, just hover over the value and it will appear in a pop-up. Handy when browsing big text values like free text descriptions.

Here, we are matching any field that begins with a letter t, with one or more of any character, up to another t. Regular expression matchers are usually greedy in that they try to match as much as possible. Here you can see they are matching all the way up to the last t in field values. 

Regular expressions let you finely filter your matching results when you are digging through your collections. In combination with Value Search’s collection, database, and server scanning, they can really power up your productivity. If you are wondering about regular expressions elsewhere in Studio 3T, check out this AMA on Regular Expressions, MongoDB and the Visual Query Builder.

Exploring regular expressions with Value Search is easy and quick. If you want to experiment with a more helpful interface, check out regex101.com where your regular expressions will automatically be explained.


How helpful was this article?
This article was hideous
This article was bad
This article was ok
This article was good
This article was great
Thank you for your feedback!

About The Author

Dj Walker-Morgan

Dj has been around since Commodore had Pets and Apples grew everywhere. With a background in Unix and development, he's been around the technology business writing code or writing content ever since.

Related articles

  • How do I use MongoDB regex (regular expressions) in Studio 3T? #Studio3T_AMA
  • The Value of Value Search – A Christmas Tale
  • Exercise 1: Using expression operators to filter input documents
  • Regular Expressions in Studio 3T
  • What’s New in Studio 3T 2021.10 | Value Search, Better Task Scheduling and Import Data Masking

Tags

2022 academy aggregation AMA atlas Certification christmas community connections culture date tags events export features hackolade import intellishell In Use JSON knowledge base migration modelling mongodb mongoodb mongosh My 3T productivity product management query regex releases schema security SQL Studio 3T studio3t tasks time series tips updates webinar windows

Browse by MongoDB topic

  • Connecting to MongoDB
  • Database Administration & Security
  • Getting Started with MongoDB
  • Getting Started with Studio 3T
  • Import/Export
  • Job Automation & Scheduling
  • MongoDB Aggregation Framework
  • MongoDB/Studio 3T Workshops
  • Performance
  • Query & CRUD Operations
  • Reference
  • Schema
  • Studio 3T Licensing
  • Support and other resources
  • Working with MongoDB & SQL
  • Working with MongoDB Atlas

Studio 3T

MongoDB Enterprise Certified Technology PartnerSince 2014, 3T has been helping thousands of MongoDB developers and administrators with their everyday jobs by providing the finest MongoDB tools on the market. We guarantee the best compatibility with current and legacy releases of MongoDB, continue to deliver new features with every new software release, and provide high quality support.

Find us on FacebookFind us on TwitterFind us on YouTubeFind us on LinkedIn

Education

  • Free MongoDB Tutorials
  • Connect to MongoDB
  • Connect to MongoDB Atlas
  • Import Data to MongoDB
  • Export MongoDB Data
  • Build Aggregation Queries
  • Query MongoDB with SQL
  • Migrate from SQL to MongoDB

Resources

  • Feedback and Support
  • Sales Support
  • Knowledge Base
  • FAQ
  • Reports
  • White Papers
  • Testimonials
  • Discounts

Company

  • About Us
  • Blog
  • Careers
  • Legal
  • Press
  • Privacy Policy
  • EULA

© 2023 3T Software Labs Ltd. All rights reserved.

  • Privacy Policy
  • Cookie settings
  • Impressum

We value your privacy

With your consent, we and third-party providers use cookies and similar technologies on our website to analyse your use of our site for market research or advertising purposes ("analytics and marketing") and to provide you with additional functions (“functional”). This may result in the creation of pseudonymous usage profiles and the transfer of personal data to third countries, including the USA, which may have no adequate level of protection for the processing of personal data.

By clicking “Accept all”, you consent to the storage of cookies and the processing of personal data for these purposes, including any transfers to third countries. By clicking on “Decline all”, you do not give your consent and we will only store cookies that are necessary for our website. You can customize the cookies we store on your device or change your selection at any time - thus also revoking your consent with effect for the future - under “Manage Cookies”, or “Cookie Settings” at the bottom of the page. You can find further information in our Privacy Policy.
Accept all
Decline all
Manage cookies
✕

Privacy Preference Center

With your consent, we and third-party providers use cookies and similar technologies on our website to analyse your use of our site for market research or advertising purposes ("analytics and marketing") and to provide you with additional functions (“functional”). This may result in the creation of pseudonymous usage profiles and the transfer of personal data to third countries, including the USA, which may have no adequate level of protection for the processing of personal data. Please choose for which purposes you wish to give us your consent and store your preferences by clicking on “Accept selected”. You can find further information in our Privacy Policy.

Accept all cookies

Manage consent preferences

Essential cookies are strictly necessary to provide an online service such as our website or a service on our website which you have requested. The website or service will not work without them.

Performance cookies allow us to collect information such as number of visits and sources of traffic. This information is used in aggregate form to help us understand how our websites are being used, allowing us to improve both our website’s performance and your experience.

Google Analytics

Google Ads

Bing Ads

Facebook

LinkedIn

Quora

Hotjar

Reddit

Functional cookies collect information about your preferences and choices and make using the website a lot easier and more relevant. Without these cookies, some of the site functionality may not work as intended.

HubSpot

Social media cookies are cookies used to share user behaviour information with a third-party social media platform. They may consequently effect how social media sites present you with information in the future.

Accept selected
✕