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.
@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.
The second find and replace removes all of the letters and leading zeros after the letters.
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.
@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?