
Try this var string_name = /^[0-9]{4}-[0-9]{4}$/; My guess is you are trying to validate a phone number? On Tue, Oct 26, 2010 at 10:03 AM, Rad! <conradakunga@gmail.com> wrote:
What i would personally do is use regular expression replacement
Your search regex will be as follows
.{4}
That will match every four characters
The replacement regex will be as follows
$&-
That will replace each match i.e. each four characters with the match and then add a dash after
On 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
Anyone got an idea of an internal PHP function that would enable me to insert a symbol e.g. '-' after every 4 characters in a String? e.g. 12345678 becomes 1234-5678.
--
Thanks and Regards, Erick Njenga Nyachwaya, M: +254-725-008-790
<http://www.facebook.com/ErickNjenga><http://www.twitter.com/ErickNjenga>
_______________________________________________ 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