1

I have been trying to get this right for awhile with no success and would appreciate some help here. Trying to parse out from the string below:

LethalWeaponFOX/photos/a.1106081639452035.1073741828.1048614701865396/1234456789011112/?type=3

The part I would like to to remove is last two forward slashes:

1234456789011112

pUrl = pUrl.replaceAll("photos\\/.*\\.","");

Appreciate suggestions:

EDIT: Sorry I needed to clarify my output and rephrase question

2
  • I just need the values between the last 2 forward slashes Commented Nov 18, 2017 at 20:20
  • 1234456789011112; guess I should rephrase the question Commented Nov 18, 2017 at 20:29

2 Answers 2

2

You'll have to split it in this case.

    String[] temp = pUrl.split("\\/");
    pUrl = temp[temp.length - 1];
Sign up to request clarification or add additional context in comments.

2 Comments

Or replaceFirst().
thanks; but I think I needed to rephrase the question. I need the value between the last two forward slashes
1

I just need the values between the last 2 forward slashes 1234456789011112

In this case you can use this regex .*\/([^\/]*)\/[^\/]*$ with String#replaceAll :

String str = "LethalWea...";
str = str.replaceAll(".*\\/([^\\/]*)\\/[^\\/]*$", "$1");

regex demo

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.