4

I have a txt with line like these ones:

155The Last Goodnight - Stay Beautiful by CapitolMusic  http://www.youtube.com/watch?v=H5c2iTcSlbE
156Sara Evans - A Real Fine Place To Start by saraevansVEVO http://www.youtube.com/watch?v=IrdCBkXB91I
157Simple Minds - See The Lights by SimpleMindsVEVO http://www.youtube.com/watch?v=MmKTMAak710

I want to remove everything before "http://..." in order to reach this result:

http://www.youtube.com/watch?v=H5c2iTcSlbE
http://www.youtube.com/watch?v=IrdCBkXB91I
http://www.youtube.com/watch?v=MmKTMAak710

Can you help me?

2
  • I can't try anything reasonable, becouse I'm new to reg exp. I've tryed to use reg exp builder as gskinner, expresso and regexpbuddy. Simply I can't understand how to start. I've tried an 1 hour before posting here (I know there are lots of know-all ready to put -1) Commented Feb 15, 2013 at 11:12
  • I get the frustration. Regex is not something that you can reference on a need to know basis, and a cheatsheet is of no use if you have never sat down and practised it, but many regex tutorials treat it as such/ assume too much. Waste of an hour! Commented Aug 26, 2013 at 8:19

2 Answers 2

22
.*(?=http://)

matches everything before the last http:// in a line.

Sign up to request clarification or add additional context in comments.

1 Comment

@user128806: Yes, just use .*? instead of .*.
2

In Java:

justHttp = justHttp.replaceFirst(".*(?=http://)", "");

For any other use just replace http:// with yourString.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.