Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6355403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:45:30+00:00 2026-05-24T22:45:30+00:00

I am trying to generate a PHP function name from URL using this regular

  • 0

I am trying to generate a PHP function name from URL using this regular expression (taken from PHP Manual – User-defined functions:

url = "controller/action,/param";
re = /[^a-zA-Z0-9_\x7f-\xff]*/g; // consecutive characters that are not in range
result = url.replace(re, "_");

I am expecting result to be controller_action_param (single underscore), but instead I am getting this as a result: _c_o_n_t_r_o_l_l_e_r__a_c_t_i_o_n__p_a_r_a_m_

I think that this is somehow connected to UTF-8/Unicode, but shouldn’t \x7f-\xff part take care of it?

JsFiddle Example

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T22:45:32+00:00Added an answer on May 24, 2026 at 10:45 pm

    Change the * to a +. The * matches zero or more of the preceding characters, you want one or more.

    re = /[^a-zA-Z0-9_\x7f-\xff]+/g;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to generate a unique ID in php in order to store user-uploaded
I have this php code, with which I am trying to generate a popup
While trying to generate classes from a xsd, i got this error: java.lang.IllegalArgumentException: Illegal
How can I generate graphs and charts from a mysql database using php? I'm
I've been trying for a while to generate an RSA keypair using PHP's openssl
I'm trying to wrtie a facebook application that generates random quotes using php. However,
I'm trying to generate customized xml files from a template xml file in python.
I'm trying to upload a picture to a specific website using php cURL but
I am trying to build a website with mysql and php. This is the
I am trying to get this class name dynamically in jquery: echo <div id=\maini\

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.