SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Zealot
    Join Date
    Jul 2003
    Location
    Romania
    Posts
    118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Some regexp help needed

    Hello guys,

    I have some song names in a file that look like this:
    Code:
    September 02:29.06Because I Love You              
    Sirens 03:37.06Club La La (Jody Den Broeder Clu
    How can I build a regexp to get rid of those numbers and return only the artist and song name?

    Thank you.

  2. #2
    SitePoint Enthusiast
    Join Date
    Jul 2009
    Location
    Austria
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try:
    PHP Code:
    match=array();
    if(
    preg_match('#^(.*)\d{2}:\d{2}\.\d{2}(.*)$#u',$line,$match)) // line!!!
       
    var_dump($match); // [1]=>artist, [2]=>song name 

  3. #3
    SitePoint Zealot
    Join Date
    Jul 2003
    Location
    Romania
    Posts
    118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you blubb!

  4. #4
    SitePoint Zealot
    Join Date
    Jul 2003
    Location
    Romania
    Posts
    118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Got an issue with that code now. Looks like the output has changed and now it can look like this:

    Code:
    Akon           Sorry Blame It On Me
    or like this:
    Code:
    Akon      feat. Someone       Sorry Blame It On Me
    How can I modify it in order to match each situation?

    Thanks in advance

  5. #5
    SitePoint Zealot
    Join Date
    Jul 2003
    Location
    Romania
    Posts
    118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Any ideea for this, blubb?

  6. #6
    @php.net Salathe's Avatar
    Join Date
    Dec 2004
    Location
    Edinburgh
    Posts
    1,397
    Mentioned
    63 Post(s)
    Tagged
    0 Thread(s)
    Can you give more examples of what will be provided? For instance, will there always be multiple spaces between artist and song title; will the song title itself ever have multiple spaces; how do you know whether it's "Akon feat. Someone" and "Sorry..." versus "Akon" and "feat. Someone Sorry..."; does the code still contain the old format as well, with the track times?
    Salathe
    Software Developer and PHP Manual Author.

  7. #7
    SitePoint Zealot
    Join Date
    Jul 2003
    Location
    Romania
    Posts
    118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Now the format can be: "Artist name Second artist name Song name" or "Artist name Song name". There will always be more than one space between artist name and song name.


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
  •