Regular Expressions with Parse 22 Dec 2011

When writing mobile applications it's important to minimize the amount of data sent over the network. Our goal with Parse is to make this easy, so your app runs as fast as possible. Along these lines, we've just launched regular expression filtering with Parse queries.

You can now provide any regular expression to a Parse query and filter the return data based on it. For example, let's say you're storing full names in the name field of a user, and you want to search for all users whose name starts with Jimbo and log their full name. To fetch this data in iOS:

PFQuery *query = [PFQuery queryForUser];

// Require that name start with Jimbo
[query whereKey:@"name" matchesRegex:@"^Jimbo"];

// Issue the query
[query findObjectsInBackgroundWithBlock:^(NSArray *users, NSError *error) {
    if (error) return;

    // Users now contains the users named Jimbo.
    for (PFUser *user in users) {
        NSLog(@"name: %@", [user objectForKey:@"name"]);
    }
}];

There are also helper functions for the specific cases of matching prefixes, suffixes, and containing a string.

// A simpler way to require that name start with Jimbo
[query whereKey:@"name" hasPrefix:@"Jimbo"];

// Requires that name ends with Jenkins
[query whereKey:@"name" hasSuffix:@"Jenkins"];

// Accepts any address containing "Parker St"
[query whereKey:@"address" containsString:@"Parker St"];

This functionality is now available for iOS, Android, and via the REST API. Read more about it in the iOS documentation, Android documentation, or REST documentation.

Your feedback is always really helpful to us as we figure out what we should build next. We're always listening, so let us know what you're building on Parse, and how we can help you build your app. Get in touch at feedback@parse.com.

Thanks for reading!

Posted on 22 Dec 2011
By Kevin Lacker
blog comments powered by Disqus

About Parse

Parse is the easiest way to get a backend up and running for your mobile application. Sign up now!

Archives

16 May 2012 ACLs in the Data Browser
10 May 2012 A Redesigned App Management Console
07 May 2012 Express Your Brand With Parse
04 May 2012 Changelogs
30 Apr 2012 Managing Push Subscriptions with Installation Objects
26 Apr 2012 AnyWall: An Example Geolocation App with Tutorial
24 Apr 2012 Protect Your App By Limiting User Authentication Methods
23 Apr 2012 A Beautiful Login Screen For Your Mobile App
10 Apr 2012 Discovering a Major Security Hole in Facebook's Android SDK
03 Apr 2012 Introducing App Email Settings
02 Apr 2012 Protect User Data With New Parse Features
28 Mar 2012 Parse supports many to many relations
26 Mar 2012 Parse is officially out of beta
26 Mar 2012 Parse 1.0 is released!
09 Mar 2012 One Click Export
07 Mar 2012 Better Pushing from Your Browser
02 Mar 2012 A Powerful Data Browser
01 Mar 2012 Link to Facebook and Twitter Now Available Through the REST API
01 Mar 2012 Usage and Analytics
27 Feb 2012 Parse Now Supports Sign in with Twitter
24 Feb 2012 Viewing the Status of Push Notifications
17 Feb 2012 Saving Data while Offline
16 Feb 2012 Building HTML5 Mobile Apps with Parse and Tiggzi
07 Feb 2012 Facebook Users: Now On Android!
31 Jan 2012 Why Building a Mobile App is Hard
30 Jan 2012 Networking Improvements in PFFile and ParseFile
25 Jan 2012 Uploading Files via REST API
19 Jan 2012 Javascript and User Authentication for the REST API
16 Jan 2012 Migrating SimpleGeo Customers: Idea to Production in One Day
11 Jan 2012 Designing Great API Docs
30 Dec 2011 Tutorial: Make a Remote Data Table in Minutes
30 Dec 2011 Query Improvements and Happy New Year
28 Dec 2011 Parse Powered iOS Table Views
22 Dec 2011 Regular Expressions with Parse
09 Dec 2011 Geo Queries
07 Dec 2011 Counters on Parse
06 Dec 2011 Including Related Objects in Queries
30 Nov 2011 Video Tutorials on Getting Started
29 Nov 2011 Performance and Security Improvements
08 Nov 2011 User Management in the REST API
04 Nov 2011 New Tricks With Queries
28 Oct 2011 Large File Support for Android
24 Oct 2011 Large File Support and Facebook Users
19 Oct 2011 Parse in the Appcelerator Marketplace
05 Oct 2011 Introducing Our Future Pricing
03 Oct 2011 Parse is now compatible with ARC
30 Sep 2011 Easy Caching with Parse
20 Sep 2011 Use Parse with Heroku
09 Sep 2011 Use Parse with Appcelerator or Sencha
06 Sep 2011 Client Permissions
26 Aug 2011 The Parse REST API
19 Aug 2011 Android User Management, Date, and Bytes
04 Aug 2011 Funding, Y Combinator, and the People Behind Parse
25 Jul 2011 Android Push Notifications
20 Jul 2011 User Accounts
18 Jul 2011 Channels and Targeted Push Notifications
15 Jul 2011 iOS Push Notifications
06 Jul 2011 The New Data Browser and Importing
05 Jul 2011 Hello World!