Search code examples
regexgrailsfindby

Grails findByName Regex


I have a domain-class called option. There is an attribute called name.

The names are like:

abc.1
abc.2
xxx.1
xxx.2
xxx.3

I want all options that start with abc. Normally I use Options.findByName("xyz") But i want all that start with abc. So in that example:

abc.1
abc.2

The regex could be /abc(.).*/

But where I have to write that?


Solution

  • If you need only simple "startsWith" condition, you can use like:

      Options.findAllByNameLike("abc%")