Link to home
Start Free TrialLog in
Avatar of fylix0000
fylix0000

asked on

How to get this substring?

"C:\ViaSafe\Channel/boaTest/BoaFromExtract/report/done/1151076810520.0@BoaFromExtract.boaTest.A6.txt.ExtractReport.pdf"

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.
ASKER CERTIFIED SOLUTION
Avatar of hoomanv
hoomanv
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of fylix0000
fylix0000

ASKER

Tried to run this but the compile method does not seem to work, I check for Patter.method in my IDE but could not see compile either.
have you imported java.util.regex.* ?
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.
what is the exact phrase of compile error ?
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_string.java:11)
try
java.util.regex.Pattern p = java.util.regex.Pattern.compile("BoaFromExtract\\.boaTest\\.(.+)\\.ExtractReport\\.pdf");
Actually , nevermind...somehow my IDE put in import com.sun.org.apache.xalan.internal.xsltc.compiler.Pattern;



will try again, as I took it out and looks good so far.
Thank you, worked like a charm :)