Java: How to return single char after string

Posted by newSpringer on Stack Overflow See other posts from Stack Overflow or by newSpringer
Published on 2012-09-06T15:25:35Z Indexed on 2012/09/06 15:38 UTC
Read the original article Hit count: 157

Filed under:
|
|

I have a file directory which could look like either

C:\projects\lab3\test\test.java

or

C:\projects\assignment3\test\test.java

But the "lab3" or "assignment3" can appear anywhere in the directory, it is not a set directory

What i want is to check to see if the directory either contains "lab" or "assignment" and get the number that follows. In this case "3"

This is what i have so far

 if(directory.toLowerCase().contains("lab")){

 } else if (directory.toLowerCase().contains("assignment")){

 }

but i do not know how to check for the char straight after the word?

© Stack Overflow or respective owner

Related posts about java

Related posts about string