Jump to content

[SOLVED] php reg ex to javascript


anatak

Recommended Posts

Hello I have a php reg ex that I want to use in javascript.

I am trying to translate it to javascript but I am failing.

 

here is the php

$handle_legit = ereg("^[a-zA-Z0-9]{2,16}$", $userhandle);
	if(!$handle_legit){
		$invalid_handle = 1;
	}

 

any idea how this would look into javascript ?

I was thinking something like this but I don't get the escaping right.

var filter=<translated regex from php> ;
if (filter.test(str)){
	testresults=true;
}else{
	alert(text);
	testresults=false;

 

kind regards

anatak

Link to comment
https://forums.phpfreaks.com/topic/42952-solved-php-reg-ex-to-javascript/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.