SitePoint Sponsor

User Tag List

Results 1 to 10 of 10

Thread: RegEx Help

  1. #1
    SitePoint Enthusiast Cory R's Avatar
    Join Date
    Mar 2009
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    RegEx Help

    What's the RegEx for this?

    <strong>31,412</strong><br>

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by Cory R View Post
    What's the RegEx for this?

    <strong>31,412</strong><br>
    What are you intending to match?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Enthusiast Cory R's Avatar
    Join Date
    Mar 2009
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I need to match the aforementioned text so I can remove it with jQuery. Here's what I have:

    Code:
    <script type="text/javascript">
    $('#stats td:contains(Total Forum Posts)').html($('#stats td:contains(Total Forum Posts)').html().replace(/Total Forum Posts:/gi,''));
    </script>
    I just need the RegEx to match any number in that thousand, since the match never stays the same as posts increase.

  4. #4
    Avid Logophile silver trophy
    ParkinT's Avatar
    Join Date
    May 2006
    Location
    Central Florida
    Posts
    2,343
    Mentioned
    192 Post(s)
    Tagged
    4 Thread(s)
    Code:
    .replace(/\d*/g, '')
    will remove all digits. But, if you expect a comma and/or dot (for decimal) you should use
    Code:
    .replace(/[0-9,.]*/g, '')
    But, since you have access to the TD that "contains" this text, can't you simply replace the entire contents of that cell? That would avoid the complexity (and the necessity) of a RegExp.
    Last edited by ParkinT; Feb 26, 2012 at 09:55.
    Don't be yourself. Be someone a little nicer. -Mignon McLaughlin, journalist and author (1913-1983)


    Git is for EVERYONE
    Literally, the best app for readers.
    Make Your P@ssw0rd Secure
    Leveraging SubDomains

  5. #5
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Which forum software are you using, in case there's a built-in way to do the same thing?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  6. #6
    SitePoint Enthusiast Cory R's Avatar
    Join Date
    Mar 2009
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    $('#stats td:contains(Total Forum Posts)').html($('#stats td:contains(Total Forum Posts)').html().replace(/Total Forum Posts: [0-9,.]*/g, '');
    I ran that in Firebug and I get this: http://prntscr.com/6ivs0

    I'm not sure how you would replace the entire contents of a cell with jQuery while keeping the statistics still in check.

    I'm using ZetaBoards and it does not have the option to remove individual lines from the board statistics.

  7. #7
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by Cory R View Post
    Code:
    $('#stats td:contains(Total Forum Posts)').html($('#stats td:contains(Total Forum Posts)').html().replace(/Total Forum Posts: [0-9,.]*/g, '');
    I ran that in Firebug and I get this: http://prntscr.com/6ivs0

    I'm not sure how you would replace the entire contents of a cell with jQuery while keeping the statistics still in check.

    I'm using ZetaBoards and it does not have the option to remove individual lines from the board statistics.
    There's a mod that removes the board total number of members count - http://resources.zetaboards.com/topic/500148/1/
    It's likely then that there is also a mod that removes the total form posts count too.

    Oh look, perhaps this one. Remove post count - http://resources.zetaboards.com/topic/5079033/1/
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  8. #8
    SitePoint Enthusiast Cory R's Avatar
    Join Date
    Mar 2009
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The first link links to an InvisonFree code. InvisonFree and Zetaboards are on the same network, but they are two different software's.

    The second link links to a code that removes post count in the user details in posts, not the statistics.

  9. #9
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by Cory R View Post
    The first link links to an InvisonFree code. InvisonFree and Zetaboards are on the same network, but they are two different software's.

    The second link links to a code that removes post count in the user details in posts, not the statistics.
    This is the first that I've heard of or dealt with zetaboard here. I think that you may be better served by posting your query in the forum that is dedicated to zetaboard matters. That way you will have access to people with a great depth of knowledge in zetaboard matters.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  10. #10
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    I suspect that an appropriate zetaboards forum is at Zathyus Networks Resources > Requests Corner > Codes & Modifications
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


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
  •