Cannot use function regex_replace (Code: undefined)

We’re unable to create a new transform rule.

Here’s what we’re using.

When incoming requests match…
starts_with(http.request.uri.path, “/guide/”) and not http.request.uri.query contains “guide”

Then… Rewrite Path

Rewrite to… Dynamic
regex_replace(http.request.uri.path, “^/guide/tim/(.*)", "{1}”)

On save of draft or deploy, we get the error:
cannot use function regex_replace (Code: undefined)

This is really vague and I can’t seem to figure out what the underlying issue is.

Looks like my formatting didn’t work. Also worth pointing out that the rewrite has the dollar sign in it before the group ID.

Update, just realized that regex support is not available in Pro plans for some reason. :frowning:

Hi Rob,

You’re right - the regex functions are only available to Biz/Ent zones. This is the same on Firewall Rules, also. We need to make the error message much more helpful, however. I’ve raised a ticket with the team and we’ll address ASAP.

Thanks for bringing this to our attention!


I’m a new user, and just spent 2 hours around this… to find out that regex support is not available in Pro.

Not very nice. Regex should be on the Pro plan!
But at least you should either display only the available options for the active plan, or update the error.

If regex is not available in Pro plans, it means there’s no dynamic rewrite?
Or is there another way?

I, too, really wished regex support was available without having to jump to the next plan. We don’t use many other features that merit using the Business plan.

Oh boy, that’s annoying! Thanks for flagging all.

Spent a good 30 minutes tweaking my regex to eventually find this thread. An error indicating that I couldn’t use this on the free plan would be good.

I also spent a few minutes wondering what this error was about.
Please, count my +1 to get this fixed.

Hello, 6 months later the bug is still here, a simple warning message could be appreciated.

Where are you looking? I tried replicated on a free zone and i see an error message now:
Screenshot 2021-10-15 at 12.44.37

I have still the same error « Code: undefined » when I try to use regex URL Transform
In my case the full error is: « Filter parsing error (1:43): regex_replace(http.request.uri.path, “^/(\d+)..html(.)”, “/${1}.html”) ^ expected ", xHH or OOO after \ (Code: undefined) »

I’ve choose URI match the regex:

Then I’ve choose Dynamic storage transformation:
regex_replace(http.request.uri.path, “^/(\d+)..html(.)”, “/${1}.html”)

So all /[ID]-whatever.html will in reality open the file name /[ID].html

May be I’ve done it wrong, but by searching on the forum the error « Code: undefined » I’ve found this thread, and indeed it’s not really explicit when we subscribe but this so useful service seems to be reserved to Business subscription only, Free and Pro account can’t

EDIT: BTW, we’re in a Pro account, not on a Free account, may be the message warning have been fixed for Free accounts but not for Pro accounts ?

Thanks for sharing your rule, thats very helpful. Ive just replicated and it appears to be an issue with the regex itself:

'(http.request.uri matches “^/\d±..html")’ is not a valid value for Expression because the expression is invalid: Filter parsing error (1:28): (http.request.uri matches "^/\d±..html”) ^^^^^^^^^^^^^^ regex parse error: ^/\d±.*.html ^ error: Unicode not allowed here (Code: undefined)

I imagine whats happening is we are attempting to validate the regex before we send it for processing, therefore we are failing and showing an error message for ‘invalid regex’ first, rather than ‘plan not entitled to regex’.

1 Like

BTW, do you known if Cloudflare have any plans to permit to have theses regex feature in the Pro plan ?
We’ve forced to choose another platform than Cloudflare just because of this, and the gap between Pro and Business is really too much for just add us this so simple feature :’(

Not that i’m aware of, unfortunately. Let me raise this internally and see what we can do.

1 Like

Thank @smarsh, or why not also a simple extra fee to have this feature in the Pro plan! :slight_smile:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.