fylix0000
asked on
How to get this substring?
"C:\ViaSafe\Channel/boaTes t/BoaFromE xtract/rep ort/done/1 1510768105 20.0@BoaFr omExtract. boaTest.A6 .txt.Extra ctReport.p df"
The above is a string which I want to get the "A6.txt" out of it, the substring after it ".ExtractReport.pdf" and the string before it "@BoaFromExtract.boaTest." will always be constant. However, the A6.txt can varies in size as I can have A12312321.txt, B23424.txt ect......
I know this has to do with Substring manipulation and trimming my string but I can not seem to come up with a clean method to do it, please help.
Thanks.
btw I store the orignal string in a String array.
The above is a string which I want to get the "A6.txt" out of it, the substring after it ".ExtractReport.pdf" and the string before it "@BoaFromExtract.boaTest."
I know this has to do with Substring manipulation and trimming my string but I can not seem to come up with a clean method to do it, please help.
Thanks.
btw I store the orignal string in a String array.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
have you imported java.util.regex.* ?
ASKER
I had import import java.util.regex.Matcher; only before
but eafter I put in import java.util.regex.*; then i still get the same error.
Focus on error gives me : The method compile(ClassGenerator, MethodGenerator) in the type Expression is not applicable for
the arguments (String)
Sorry I am quite new to this Pattern so I am kind of clueless.
but eafter I put in import java.util.regex.*; then i still get the same error.
Focus on error gives me : The method compile(ClassGenerator, MethodGenerator) in the type Expression is not applicable for
the arguments (String)
Sorry I am quite new to this Pattern so I am kind of clueless.
what is the exact phrase of compile error ?
ASKER
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The method compile(ClassGenerator, MethodGenerator) in the type Expression is not applicable for the arguments (String)
The method matcher(String) is undefined for the type Pattern
at name_string.main(name_stri ng.java:11 )
The method compile(ClassGenerator, MethodGenerator) in the type Expression is not applicable for the arguments (String)
The method matcher(String) is undefined for the type Pattern
at name_string.main(name_stri
try
java.util.regex.Pattern p = java.util.regex.Pattern.co mpile("Boa FromExtrac t\\.boaTes t\\.(.+)\\ .ExtractRe port\\.pdf ");
java.util.regex.Pattern p = java.util.regex.Pattern.co
ASKER
Actually , nevermind...somehow my IDE put in import com.sun.org.apache.xalan.i nternal.xs ltc.compil er.Pattern ;
will try again, as I took it out and looks good so far.
will try again, as I took it out and looks good so far.
ASKER
Thank you, worked like a charm :)
ASKER