How to do dynamic RegEx?

I want to create a regular expression based on a user input from a search field. Using this regex, I want to filter a list of objects.
This one works:


However, I want to have a user defined search term, so I was trying this:

where the variable regex is set to:

This leads to the following error:

bundle.js:23 Uncaught (in promise) TypeError: regex.test is not a function
    at callback (bundle.js:23)
    at bundle.js:28
    at Proxy.map (<anonymous>)
    at bundle.js:26
    at Object.onClick (bundle.js:34)
    at runHandler (sdk.js:14)
    at i.available.n.<computed> (sdk.js:14)
    at Object.ba (sdk.js:14)
    at ja (sdk.js:14)
    at ka (sdk.js:14)

I also noted that I can only connect raw text to “pattern/regexp” plug. That’s why I used raw text when defining regex variable.

So, how to build a dynamic regex?

Regards,

Hello @Klaas_Klever

Seems like there is no way to specify a dynamic RegExp, thank you for pointing us about that!
I just created an internal ticket BKNDLSS-25836 to add that block.

However, for implementing a simple search you do not need the RegExp block, it can be done with a simple string contains block:

Take a look at this demo: https://backendlessappcontent.com/7E25B48A-05FA-0B5D-FFAE-63CC0AC26C00/A09B7B01-A9D5-43E6-AF33-6A774E4BB455/files/ui-builder/containers/default/index.html?page=RegSearch

Regards, Vlad

Yes. I can use String contains to start with, but Regex will be much more powerful.
Regards

could you please provide cases where you need RegExp for this kind of search?

For instance, regex offers an OR operator, and wildcards.

ok, it makes sense

Hello @Klaas_Klever

We have added a new Codeless block to specify a dynamic RegExp. The old block will be deprecated

Regards,
Inna

@Inna_Shkolnaya
Great! I will try …
Regards