• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to regexes with negations / exceptions

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

I need your help to advice on how to include a few exceptions from the following regexes:

I can use multiple Java string matches and combine them with booleans to achieve the same objectives but would like to find out how the regexes work on their own.

Thanks in advance,

Jack
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jack Bush wrote:I can use multiple Java string matches and combine them with booleans to achieve the same objectives but would like to find out how the regexes work on their own.


Then my suggestion would be to find a good tutorial. I'm a reasonably advanced regex user (old Unix sysadmin), and even I would tackle this in stages:
1. Get your "words".
2. Run much simpler regexes against each word.

The trouble with trying to do it all at once is that you're likely to end up with a huge (and extremely arcane) expression that has to be documented
for the next poor soul who has to look at your code - which may be you in a few years time when you've forgotten what you were trying to do.

Winston

BTW - Could you possibly reduce the line length on your posts? It's a bit of a pain having to scroll backwards and forwards constantly.
 
Jack Bush
Ranch Hand
Posts: 235
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for this valuable advice Winston,

I need to strike the balance between keeping the codes simple for ease of maintenance while trying
to exploit the power of regex.

Jack
reply
    Bookmark Topic Watch Topic
  • New Topic