Find & Replace: case sensitive workaround

So as you can see from the images below, I’m using the input to search for questions & answers that contain the word “Star” or “star”. The search is case insensitive which is great! The question is displayed in both scenarios.

However when I use the “find & replace” function to change the color of the text being searched to blue, the “find & replace” function is case sensitive.

Is there a simple solution to this? @emmanuel, would it make sense to add a “make case insensitive” checkbox when using the “find & replace” function?

Thanks everyone!

2 Likes

It would also be great to allow modifiers within the pattern …

http://www.regular-expressions.info/modifiers.html

3 Likes

There are the complex solutions …

A. Make both strings lowercase, search for the position and length of the matching substring, then insert the appropriate markers.

B. Use javascript functions.

1 Like

I don’t see how I’d go about executing option A. And I’ll try to avoid option B if I can!

Option A is a dog’s breakfast, because of the text functions limitations …

2 Likes

That’s a TON of work. You’re a boss for this! I’ll try it out on my app.

You’re welcome, but I still think its an awful solution! : )

1 Like

haha The javaScript option wouldn’t be simpler?

Yes, see the “js” page : )

1 Like

A LOT better! haha. I’m currently trying to make it work dynamically for a list of things.

I actually think I’m going about this entire process the wrong way.

When not using a dynamic list, the JS works perfectly. Oh well. I’ll figure something out along these lines. Thanks for all of your help!

My suggested approach had a bunch of assumptions about the workflow …

Can you describe in more detail what you want to happen, and when it should happen?

INSTRUCTION: Search “lorem” and then click out of the input box to see the JavaScript result at the bottom of the page.

I’m almost there. As you can see, when the user searches, items are displayed that contain the input’s value. All the way at the bottom is the result of the JavaScript (I changed it around a little). 2 things would solve this problem.

  1. Instead of the blue “test” (see result at the bottom), it would be the EXACT word from the database. If it’s lowercase in the database, it’ll be lowercase in the result. Same with capitalized. The problem I had before was that I was using the value of the Input which will either be lowercase OR capitalized already.

  2. If the “result” didn’t need a workflow to be displayed. Meaning the text was automatically changed when the search is going on.

Does that make sense?

I’ve fixed up the example regex in the “js” page to do this, it uses grouping.

I added another page “js-rg” to show this, no workflows.

In the repeating group cell, there is an Expression to run the javascript regex and send it to a Javascript To Bubble element in the same cell.

Your app looks fun : )

2 Likes

Great, I’ll make the adjustments and let you know how it goes. And this is somewhat of a test site I’m going to present to the company. Want to collab/partner with them.

1 Like

It WOOOOORRRRRKKKKKSSSSS!!! Cheers Mishav. You’re a legend!

1 Like

For anyone else trying this, make sure you use your Debugger. If a search happens when the page is loaded, you will have a different “process” than if the user needs to type in the input box once the page is loaded to trigger the first search.

Post below if you have any questions!

I found an interesting error @mishav.

When the question I’m searching uses “”, an error occurs. My solution to this was to change the “” to ‘’. That worked fine but is there anyway you see a way to still have “”?

See example below

When using ‘’ in the question, everything is perfect!

When using “” in the question, there is an error, resulting in not displaying the question.

No biggie if you can’t solve it. I spent about 30 mins figuring out what the problem was in the first place haha.
Here’s another image of the JavaScript

Well done finding that corner case!

Double quote messes up the javascript syntax because it is being used as a delimiter in the expression.

To fix this, need to escape the escape character, and the quote character.

To do this, use two find & replace operations:
replace \ with \\
replace " with \"

Or both at once with a regular expression:
replace (\"|\\) with \$1

Similarly, the text pattern needs to escape its delimiter / and the escape character:
replace (\/|\\) with \$1

I’ve updated the demo “js” and “js-rg” pages …

1 Like

guess what? It worked! Good shit.

1 Like