Blog

Using regular expressions on SES routes

Luis Majano May 10, 2010

Spread the word

Luis Majano

May 10, 2010

Spread the word


Share your thoughts

With ColdBox 3.0.0 you can use any kind of regular expression with your SES routes which makes it extremely flexible.  One way to accomplish this is by using the constraints arguments when calling the addRoute() method to add a routing entry. So if I wanted to add a placeholder that matches a regex then I would do this:

addPattern(pattern="/api/:format/", constraints={format="(xml|json)"})

As you can see from the code above, the constraints argument is a structure in which the keys match a :placeholder in the pattern string.  Then you start of the values with a parenthesis so the expression can be grouped and match and then I place my regex, which in my case is a simple xml or json value.  However, you can get very funky and use your own regular expressions on ANY placeholder.

Add Your Comment

Recent Entries

Copy of BoxLang AI 3.4 Blog Series Part 5 : Reasoning Without the Guesswork

Copy of BoxLang AI 3.4 Blog Series Part 5 : Reasoning Without the Guesswork

Reasoning-capable models have been usable in BoxLang AI for a while. params passes straight through to the provider body, so params: { thinking: { type: "enabled", budget_tokens: 10000 } } for Claude, or params: { reasoning_effort: "high" } for OpenAI, already reached the API. What never worked was reading the reasoning back. It was parsed out on arrival and silently dropped. In 3.4.0, that's fixed, and it's fixed the same way for every provider.

Luis Majano
Luis Majano
September 15, 2026
BoxLang 1.17 Series Part 4 : WriteDump Enhanced!

BoxLang 1.17 Series Part 4 : WriteDump Enhanced!

You call writeDump() on an ORM entity or a very rich class graph . The browser locks up. Thirty seconds later you get a page with forty thousand rows on it, you scroll for a while, you give up, and you go edit your code to dump a sub-key instead. Or worse, you crash the server.

Luis Majano
Luis Majano
September 11, 2026