0

i split the strings below by the last / of the path:

html/body/div/div/table/tbody/tr/td/div/table/tbody/tr/td/table/tbody/tr/td/font/table/tbody/tr/td/p = Infoprat
html/body/div/div/table/tbody/tr/td/table/tbody/tr/td/table/tbody/tr/td/a = 547 astuces Windows 95/98
html/body/div/div/table/tbody/tr/td/table/tbody/tr/td/table/tbody/tr/td/p = Infoprat

and i got this result :

html/body/div/div/table/tbody/tr/td/div/table/tbody/tr/td/table/tbody/tr/td/font/table/tbody/tr/td
html/body/div/div/table/tbody/tr/td/table/tbody/tr/td/table/tbody/tr/td/a = 547 astuces Windows 95
html/body/div/div/table/tbody/tr/td/table/tbody/tr/td/table/tbody/tr/td

but in the second line , because of a the / in 547 astuces Windows 95/98 , it didnt work. how can i ignore this / in 547 astuces Windows 95/98 ?

my code is :

line = line.substring(0,line.lastIndexOf("/"));
2
  • 1
    You can first split with = followed by splitting with / on the first element of the array. Commented Mar 21, 2016 at 7:58
  • yeeeees it works :D thanks paramod Commented Mar 21, 2016 at 8:00

1 Answer 1

1

You can split the string with = and then perform the required operations on the first element of the array returned by the split operation.

line = line.split("=")[0];
// input: html/body/div/div/table/tbody/tr/td/table/tbody/tr/td/table/tbody/tr/td/a = 547 astuces Windows 95/98
// output: html/body/div/div/table/tbody/tr/td/table/tbody/tr/td/table/tbody/tr/td/a 
Sign up to request clarification or add additional context in comments.

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.