SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    May 2009
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Regular expression help

    Hi,


    Plzz help me out

    I need a regular expression to replace ,, comma's in string with zero.

    example : 1,20,30,,40,,,,90,,

    answer should be : 1,20,30,0,40,0,0,0,90,0


    Thanks

  2. #2
    SitePoint Wizard silver trophy rushiku's Avatar
    Join Date
    Dec 2003
    Location
    A van down by the river
    Posts
    2,056
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    0: Review the Pattern class to see how to construct a regex, pay attention to characters that have special meaning.

    1: Determine the pattern you want to match, in String.replaceAll(), this will be the regex argument.

    2: Determine what you want replace the matched pattern with, this will be the replacement argument.

    3: Write a small class, maybe named RegexExperiment_1, and try out your regex, test often. When it works, incorporate it into your code.

  3. #3
    SitePoint Member
    Join Date
    Jul 2009
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    komandin.org/regex/regex_view.html

    look for more examples

  4. #4
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    You've already received an answer in the PHP forum, bothering these java folk is unnecessary...



    http://www.sitepoint.com/forums/showthread.php?t=625508
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.


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
  •