Help with a Regex (regular expression)

I have little to no experience w/ RegEx, so I’m looking for a little help on how to find/extract when specific characters are grouped together in a list…Even if they are not separated from other characters. Here’s an example:
List = (234524C, 55555f, 2323F, 5545G, FFF99, Word%202343)

What I’m looking to isolate is any time a number is followed by either the letter C or F (noCase style…so f or c, as well) and then isolate those list items. So in the example above, the first list item ends in 4C (a number followed by C), so that whole list item (234524C would need to be ‘found’, if we do a listFind or listContains). The 4th and 5th list items would not be found, since 4 has no C or F and 5 has letters before the number. That’s my first conundrum… I’m also hoping to isolate any list item that has %20 in it (see last list item in example).

I’ve played with a few online regex tools, but haven’t been able to create anything that only finds cases where the number and letter are consecutive w/ the number first.

The use case is trying to block some unwanted bot type traffic, that’s spamming a website’s search form with unrealistic/unwanted search words.

Any help would be greatly appreciated!


Sean, I’ll leave others to help hopefully with your regex interest, but as for the use case and need you describe, have you considered using the csrfgeneratetoken and csrfverifytoken functions (supported by Lucee since 4.5 and cf since 10)? Using those on such a search form/action page can do much to stop spammers, who would no longer be able to just call the action page directly.

Thanks for the reply Charlie! I’ll do some research on those tags and see if that’s something we can implement here. This was just going to be a ‘quick fix’ for a client seeing some specific unwanted searches. But now it’s starting to look it could turn into a broader update to our current website search page. I’ll post any updates here, in case anyone else runs into a similar issue.

Sure, but to be clear, those two functions are VERY simple to use, only one line of code on the search form, and a couple lines of code on the action page.