1

I've written some code which utilizes the split() method to return the first item delimited by periods. After a little testing I found that the array I split the string into has a length of 0 so I assume it's not splitting at all. It may be relevant that in some cases there is no period and I want the entire string returned. To compensate for this, I added a period onto the end of each String. See below:

longText=longText+".";
String tempName[]=longText.split(".");
String realName=tempName[0];
System.out.println(realName); 
return realName;
1
  • The string that it seems to get stuck on is "Full Issue PDF Volume 1, Issue 2". Without the quotes of course. I believe it's also the first string in the series to be tested. Commented Oct 21, 2013 at 14:30

1 Answer 1

1

The method String#split takes a regular expression as an argument. See Java Doc

The following: Split String on dot . as delimiter will help you

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.