Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Nov 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How Would I Remove all instances of this?

    I want to remove every instance of this that I find:

    Ad ID: 12323500

    ....where "Ad ID: " will always be the same, but the number after it will always be different. It will always be a 8-digit number though.

    I'm a php newb and I usually just use str_replace to get rid of stuff I don't want but wasn't sure how to approach it in this situation.

    Thank you!!

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,592
    Thanks
    0
    Thanked 645 Times in 635 Posts
    use preg_replace instead of str_replace so you can use a regular expression.

    The following regul;ar expression will match every occurrence of your Ad ID provided that it is followed by an eight digit number

    /Ad ID: \d{8}/
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #3
    New to the CF scene
    Join Date
    Nov 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    Quote Originally Posted by felgall View Post
    use preg_replace instead of str_replace so you can use a regular expression.

    The following regul;ar expression will match every occurrence of your Ad ID provided that it is followed by an eight digit number

    /Ad ID: \d{8}/
    Thank you so very much. Worked perfect!!


  •  

    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
    •