We help IT Professionals succeed at work.

Regular Expression or Regex

bcmchong
bcmchong asked
on
506 Views
Last Modified: 2013-11-05
I am trying to write a Regex or Regular Expressions to catch the following, any help/guidance would be much appreciated...
Employee ID
employee ID
employee iD
employee id
employee Id
employeeID (no spaces in the string)
employeeiD
employeeiD
employeeId
and so on.....
Comment
Watch Question

Top Expert 2009

Commented:
/Employee *ID/i
Kim RyanIT Consultant

Commented:
if ( $str =~ /employee\s?id/i)
{

}
Kim RyanIT Consultant

Commented:
# search for your string ignoring the case (i option)  with an optional space between words
if ( $str =~ /employee\s?id/i)
{
  print "word found\n";
}
bcmchongSystems Engineer

Author

Commented:
I am using RegexBuddy and each of your suggestions have failed to match. I tested with the following:

Employee ID
employeeid
employee id

Also getting errors with the '/'. Should this be an escape with '\'?
Kim RyanIT Consultant

Commented:
As this is the perl area, the answers use perl style regexs  If you can explain what the RegexBuddy syntax is we may be able to give a solution for that tool.
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
CERTIFIED EXPERT

Commented:
Just type this in the pattern line in Regex Buddy:
Employee *ID

Note that this what Adam314 recommended initially.  Regex Buddy appears to assume case-insensitivity.
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Commented:
Why don't you use Perl. It is absolutely free and very powerful.
@mjcoyne:

When I was a rookie with regex, and new to Perl, I used to use Regex-Coach to understand regex. It is a very good learning tool. But now I can write regex without any tool. Same goes for any learning process, right? There has to be a time when someone is rookie enough in some technologie to be unsure. But again, I respect a wizard's opinion.
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.