Results 1 to 2 of 2

Thread: Remove Commas from Numbers and Leave Commas between Words

  1. #1
    Join Date
    Feb 2010
    Posts
    25
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Remove Commas from Numbers and Leave Commas between Words

    Dear forum,
    I need to remove commas from numbers and leave commas between words, but I can’t find regular expression that does this. Numbers are always same without whitespace characters (1,234) but text can be different (with whitespace characters on both side, on left, on right side of comma, or without white spaces) like:
    one,two
    tree , four
    five, six
    seven ,eight
    Can please somebody help me with this.

  2. #2
    Join Date
    Feb 2010
    Posts
    25
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    preg_replace('@(\d),(\d)@', '$1$2', $string);

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •