www.webdeveloper.com
Results 1 to 3 of 3

Thread: [RESOLVED] preg_replace pattern. need help

  1. #1
    Join Date
    Sep 2008
    Posts
    61

    resolved [RESOLVED] preg_replace pattern. need help

    Hi!

    I'm trying to figure out how to write the regexp pattern for a text which consists of many values. ex. "1,3,55,7" or "4,2,7,3,6,8,13,33,453". So the amount of values does not matter, and the separator shall be ",".

    Thanks!
    Artheus

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,330
    Code:
    '/[0-9]+(,[0-9]+)+/'
    Change the last "+" to a "*" if you also want to replace a number with no commas, e.g. "53".
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Sep 2008
    Posts
    61
    Thank you!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles