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 6066157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:28:14+00:00 2026-05-23T09:28:14+00:00

When an key is pressed in an input I call this on its value

  • 0

When an key is pressed in an input I call this on its value

.trim().replace(/ /g, '.').replace(/[^\w .-]/gi, '').toLowerCase();

what I want to do is, when the value is submitted to the server I want to do a function that will take the value, fun the php version of this function over it, and if the new string is different to the original string return false, else return true.

So, What is the php equivelent of the above line of code?

obviously I can use strtolower(str_replace(' ', '.', trim($value)))

which means I just need to equivelent of .replace(/[^\w .-]/gi, '')

  • 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-23T09:28:15+00:00Added an answer on May 23, 2026 at 9:28 am
    preg_replace('/[^\w .-]/', '', $subject);
    

    Notes: The global flag g is not needed in php. Flag i is not necessary for \w.

    And as a side note: You don’t actually need the space in the character class because you removed spaces already.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My code is $('input').live('keypress', function(event) { if (event.keyCode === 37) console.log(left key pressed); else
From an input text I need to call a function to capture the onkeydown
I have a form with an <input type=text /> and I want to call
A timer to fire an AJAX call if no key is pressed. If a
I want a script to verify if the key pressed is 'spacebar', keycode 32.
How do I submit an HTML form when the return key is pressed and
With jQuery, how do I find out which key was pressed when I bind
Is there any way to find out if the user pressed the delete key
I have an interface that needs to react to long key presses. That means
Given the key for some registry value (e.g. HKEY_LOCAL_MACHINE\blah\blah\blah\foo) how can I: Safely determine

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.