Try this
var string_name = /^[0-9]{4}-[0-9]{4}$/;
My guess is you are trying to validate a phone number?
What i would personally do is use regular expression replacementYour search regex will be as follows.{4}That will match every four charactersThe replacement regex will be as follows$&-That will replace each match i.e. each four characters with the match and then add a dash afterOn Tue, Oct 26, 2010 at 9:45 AM, julianne anyim <julia.alma@hotmail.com> wrote:_______________________________________________Try this.....
$orig_string = "123456789";
$insert_string = "-";
$position = "4";
$newstring=substr_replace($orig_string, $insert_string, $position, 0);
echo $newstring;
Regards,
Julianne
From: eriknjenga@gmail.com
Date: Mon, 25 Oct 2010 20:12:49 +0300
To: skunkworks@lists.my.co.ke
Subject: [Skunkworks] PHP String Manipulation_______________________________________________ Skunkworks mailing list Skunkworks@lists.my.co.ke http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks ------------ Skunkworks Rules http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 ------------ Other services @ http://my.co.ke
Skunkworks mailing list
Skunkworks@lists.my.co.ke
http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks
------------
Skunkworks Rules
http://my.co.ke/phpbb/viewtopic.php?f=24&t=94
------------
Other services @ http://my.co.ke
_______________________________________________
Skunkworks mailing list
Skunkworks@lists.my.co.ke
http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks
------------
Skunkworks Rules
http://my.co.ke/phpbb/viewtopic.php?f=24&t=94
------------
Other services @ http://my.co.ke