Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to find the ".java" file not ends with word "Process"  RSS feed

 
Sankar Kuppusamy
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to find the ".java" file not ends with word "Process"

For example

If there are two files

XyzProcess.java
XyzHolder.java

then the result should be

XyzHolder.java

I have tried using the regex "(?i).*?(^(Process))\\.java".

But its not working as expected.

Please suggest me what is wrong with it.

Thanks in Advance
Sankar K
 
r035198x
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why not just do a !endsWith("Process.java")?
 
Sankar Kuppusamy
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thanks for your reply.

Yeah!!! As you said we can achieve the same with endWith.

But I am learning the Regex stuff. For learning purpose i want to achieve the same using Regex.

Thanks,
Sankar
 
Campbell Ritchie
Marshal
Posts: 56207
171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
r035198x wrote:Why not just do a !endsWith("Process.java")?
Please read the important administrative private message I just sent you.
 
Campbell Ritchie
Marshal
Posts: 56207
171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sankar Kuppusamy wrote:But I am learning the Regex stuff.
I presume you are familiar with the Java™ Tutorials section?
 
Sankar Kuppusamy
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Campbell Ritchie,

Yeah !!! While learning i came across various documents including the website which you have mentioned.

Based on the documents I have tried the above regex to solve my problem.

But Its not working as excepted. Also I could not figure out where the problem is.

That why i have raised this in forum.

Please help me if you know how to solve this problem.

Thanks,
Sankar.
 
Antany Vasanth
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sankar,

You can do this using negative look behind operator

"(?i).*?(?<!(Process))\\.java"

Here the above code check for the unavailability of word "Proccess" before ".java" file.


Regards,
Antany
 
Sankar Kuppusamy
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks antany
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!