Groovy =~ operator case insensitive?

Running FileBot from the console, Groovy / FileBot scripting, shell scripts, etc
Post Reply
howdymilsap
Posts: 34
Joined: 14 Jul 2018, 17:22

Groovy =~ operator case insensitive?

Post by howdymilsap » 05 Oct 2018, 00:54

I am working to reorganize a bunch of data and am running into some issue with case-sensitive naming.

I am trying to use the groovy find operator like this:

Code: Select all

 f =~ /DVDR|DVD5|DVD 5|DVD9|DVD 9/ ? 'DVD/movies' 
But I am finding that this does a case-sensitive search. Is there a way to make this case-insensitive?

User avatar
rednoah
The Source
Posts: 16094
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Groovy =~ operator case insensitive?

Post by rednoah » 05 Oct 2018, 07:53

You can add (?i) at the beginning of your regex to turn on the case-insensitive flag:
https://www.regular-expressions.info/modifiers.html

e.g.

Code: Select all

/(?i)DVD[ _.]?[R59]/
:idea: Please read the FAQ and How to Request Help.

Post Reply