• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to regexes with negations / exceptions

 
Jack Bush
Ranch Hand
Posts: 235
  • Mark post as helpful
  • send pies
  • 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
 
Winston Gutkowski
Bartender
Pie
Posts: 10527
64
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic