I’m working on a project where I need to search for people with given ID. ID’s are in the form of ABC001, ABC002 etc
The requirement is to display the user with ID ABC001 when someone searches with ID ABC1. In a sense, leading zeroes shouldn’t hold any value while searching. I’ve tried using regex and find&replace along with filters to do this, but no success.
Any help would be much appreciated.
Thanks for your response but that will replace all the zeroes. I also have IDs like ABC010, which should be returned when someone searches ABC10. And in some cases the length of ID might change to something like ABC00001 (5 digit number after text). Only leading zeroes should be ignored in all the cases.
I’m working on this regex replace but I’m not sure how the capturing groups go in Bubble. I’m going to test it out and I’ll post it when it’s finished.
.*?(0+)[^0]+.*$
Edit: I need to modify this to do a positive look-ahead give me a few more minutes to sort that out so it matches the correct part of the string. Right now it’s matching the whole string.
@maheshkasindi, feel free to ignore me here if I’m just muddying the waters. Oh, and full disclosure… I don’t pretend to know jack about regex, but I like to practice by trying to figure out answers to questions like the one in this thread when they come up.
The above being said, I have something that appears to work by doing two find and replaces on the initial string. The first find and replace uses the following regex to get rid of everything in the string that isn’t a letter.
[^A-Za-z]+
The second find and replace removes all of the letters and leading zeros after the letters.
^[a-zA-Z]+0*
So, if you put the output of those find and replaces together, you get the desired result. By the way, I am happy to be ridiculed into oblivion if using two expressions is the worst idea ever… but it works, so I’ve got that going for me, which is nice.
@mikeloc it’s not a terrible idea, I almost resorted to that and then stumbled upon the regex I finally posted (I think that one gets the job done). However, your idea and logic are sound.
@bubble.trouble, thanks for the feedback… much appreciated. Truth be told, the only reason I went down that path is because I couldn’t get the latest one you posted to work, so I wanted to see if I could come up with something. Are you sure that one works?
@bubble.trouble no with regex it all depends on the input and I only tested a few inputs. It’s very possible that a different input would cause it to fail…