Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 2 of 2
  1. #1
    Senior Member
    Join Date
    Aug 2011
    Posts
    226
    Member #
    29153
    Liked
    4 times

    Using php how can I strip out words from a text?

    For example, if the text is "artist - song.mp3", how do I take out the song name assigning them each to a new string? Each time it passes through the loop, the song will be different and different lengths and different number of words. it would have apostrophes and commas in it as well.

    Right now I have
    preg_match("/(?<=- )[A-Za-z_ ]*/", $string, $matches);
    $song = matches[0];

    but that stops when it gets to an apostrophe or to a comma. For example, if the song is "I'm Coming Home" it reads it as "I" and that's it.

  2.  

  3. #2
    Senior Member
    Join Date
    Aug 2011
    Posts
    226
    Member #
    29153
    Liked
    4 times
    Nevermind, I got it.

    preg_match("/(?<=- )[A-Za-z,' _ ]*/", $string, $matches);
    is how it should be.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 05:31 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com