• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

regex variable in FilenameFilter anon inner class

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all, anybody know what I'm doing wrong or how to make this work?
I have an anonymous inner class to filter a directory of files based on a regex pattern inputted from a system property.




usage in main:



strPattern is declared in the outer class:

and initiated in the constructor

now here's the weird part, if I use a constant declared in the outer class

or hardcode the string, it works

I've tried using/not using final keyword, using/not using Pattern compiler
no go- as long as I try to use a variable regex I don't get a match.
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you sure the String returned from System.getproperty is what you think it is ?
I noticed you are using \\ to represent a \ in a Java string. That is correct for a hardcoded String, but you only need a single \ in the property that you read in.
 
BV Boose
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you are a frickin genius!!! That's what it was- I was escaping the \ in the system property.
Thanks.

Originally posted by Joanne Neal:
Are you sure the String returned from System.getproperty is what you think it is ?
I noticed you are using \\ to represent a \ in a Java string. That is correct for a hardcoded String, but you only need a single \ in the property that you read in.

 
Marshal
Posts: 72995
330
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Joanne is a genius, and we have all known that for a long time, but please watch the words which accompany "genius." This is a family website and we don't go in for that sort of wording.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by gebuh Boose:
you are a ... genius!!!



Not really. Just years of experience of seeing problems like these (usually in my own code . )
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Joanne,
Please check your private messages.
-DOM
 
author
Posts: 3281
8
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's a shiny new title you have there Joanne, Congrats!
 
Campbell Ritchie
Marshal
Posts: 72995
330
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, Joanne, congratulations on the new handle.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much.

I got a 10% pay rise to go with it as well. Hope that wasn't meant to be a secret David
 
Sheriff
Posts: 22210
117
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What, you get paid to be here?

*storms off to Paul's office* I demand payment as well!
 
Campbell Ritchie
Marshal
Posts: 72995
330
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Joanne Neal:
Thank you very much.

I got a 10% pay rise to go with it as well.

You well deserve the "handle." But I thought Ranchers got 33% more.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Rob Prime:
What, you get paid to be here?

*storms off to Paul's office* I demand payment as well!



I had a word with Paul for you and he says you can have a 25% pay rise.
 
Campbell Ritchie
Marshal
Posts: 72995
330
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you, Joanne, that is very kind of you. I hope that applies across the board to all bartenders.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Campbell Ritchie:
Thank you, Joanne, that is very kind of you. I hope that applies across the board to all bartenders.



Apart from you, yes. Paul said something about you being a special case - not sure if that's good or bad.

And apologies to gebuh for totally hijacking the thread.
 
Campbell Ritchie
Marshal
Posts: 72995
330
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
People have been calling me a special case for as long as I can remember
 
Rob Spoor
Sheriff
Posts: 22210
117
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Joanne Neal:


I had a word with Paul for you and he says you can have a 25% pay rise.


Whoohoo!
 
What do you have to say for yourself? Hmmm? Anything? And you call yourself a tiny ad.
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic