• Post Reply Bookmark Topic Watch Topic
  • New Topic

String question  RSS feed

 
John Gregory
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a String I'd like to test if it meets certain criteria but not sure whether it
can be wrapped into one test. Here's a snapshot of what I have.

cn=smith tim j smithtj,ou=software,ou=engineering,o=MI,c=Advanced Solutions

When I look up a user in I want to do some processing on them. I want is to
check whether the dn has o=mi, regardless of case. So, it can be o=mi, or o=MI
or O=MI....etc. I don't want to have 20 different tests to see what case it matches...



I'm sure this is clear as mud.... but, if you can see through mud, I'd appreciate any
suggestions.

John
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi John,

There are two ways to do this. An easy "cheat": convert the String to all upper case before checking!



The other way is a little harder, but more flexible if your variations including more than just case differences: regular expressions. Here is a quickie introduction to regular expressions (also called "regex"), but admittedly it can be a complex subject to master. Once you have a basic understanding, though, you can do some amazingly powerful matching tasks.
 
Campbell Ritchie
Marshal
Posts: 56562
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I always found the Java Tutorials introduction to regular expressions very easy to understand.
 
John Gregory
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ernest,

Yes, that'll work fine!

I just had a brain dump on how to do that.....

Thanks,

John
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!