Jump to content

Script Filter JSON to see if title contains substring from query


Recommended Posts

I have a list of JSON objects where I want to check if a title contains a substring entered in the Alfred prompt.

 

I tried to build it with an Alfred Script Filter (JSON format) using the autocomplete. But works only if the string starts with the query string.

What I need is to check if the substring is in (contains instead of starts with) the title.

 

Given the example item below if I search for "I want" this item should be a candidate for selection in the resultslist of the script filter.

 

{"items": [

    {

        "nr": "1",

        "title": "The String I want to search in"

        "subtitle": "",

        "autocomplete": "The String I want to search in",

        "arg": "",

        "icon": {

            "path": "images/a.png"

        },

        "variables": {

            "id": "213",

            "value1": "lorem",

            "value2": "ipsum",

            "notes": "sadasd sadsad. sdasd"

        }

    },

   

 

Is this possible with a Script Filter? If not how could I achieve it? 

Link to comment
Posted (edited)

ah I have overlooked this option.

 

But this seems to work only with words. 

What I would need is matching of substring in a word.

 

Example:

 

The items are:

 

Hamburg

Dresden

Kreuzberg

Bergheim

 

 

 

if i search for "berg" both  Kreuzberg and Bergheim will be results shown in the list.

 

Edited by Marc
typo
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...