Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Regular expression to find whether line DOES NOT end with a specific pattern

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have list of directories and java files.

/usr/com

/usr/com/file1.java

/usr/com/file2.java

/usr/com/regexdir1

/usr/com/regexdir2

/usr/com/regexdir1/file3.java

/usr/com/regexdir2/file4.java

For selecting lines ending with ".java", I will use regular expression "*.java"

But for selecting list of directories, I am aware that I should select all the lines that does not match the pattern "*.java"

How will I express this in regular expression?

Any help on this is greatly appreciated. Please help.



Thanks,

T.Kingsly
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If it fails that regular expression than you should know it is a directory.

You could easily just do

Eric
 
Kingsly Theodar
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Eric Pascarello,
That looks great.
But the tool I am using accepts only Regular expression.
Any idea of using regular expression for the same?

Thanks,
T.Kingsly
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Something like this?

.*[^\.java]

Eric
 
Kingsly Theodar
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bingo. That is the one.

Thanks for sharing it Eric



Thanks,
T.Kingsly
 
Attractive, successful people love this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic