tags:

views:

16

answers:

2

the string

[playlist]numberofentries=2File1=http://66.162.107.142/cpr1_K128OV.oggTitle1=KCFR NewsLength1=-1File2=http://66.162.107.141:8000/cpr1_K128OV.oggTitle2=KCFR News BackupLength2=-1Version=2

i wanna cut all of the links in this file, how to?

A: 

Use a regular expression to find and replace the URLs. Be aware this sort of thing is fraught with peril. Post an example of what you want the end result to look like for a better answer. Are all the URLs IP addresses?

Tony Ennis
A: 

The following class

package regexpso;

import java.util.regex.*;

public class Main {

    public static void main(String[] args) {
        Pattern p = Pattern.compile("(http:.*?.ogg)");
        Matcher m = p.matcher("[playlist]numberofentries=2File1=http://66.162.107.142/cpr1_K128OV.oggTitle1=KCFR NewsLength1=-1File2=http://66.162.107.141:8000/cpr1_K128OV.oggTitle2=KCFR News BackupLength2=-1Version=2");

        while (m.find()) {
            System.out.println(m.group());
        }
    }
}

prints

http://66.162.107.142/cpr1_K128OV.ogg http://66.162.107.141:8000/cpr1_K128OV.ogg

as result.

zellus