Hi there....

I need help with a regex, I need a regex to check if the qualification types are valid, e.g. Bachelor's degree, Honours degree, National Diploma, B.Tech(BACHELOR OF TECHNOLOGY), etc...

I have to check if the user's qualification matches the reqiured qualification. I have:

        if($user_qualification == $required_qualification){
    //do something
    }

but the problem with this is that, the user might have:BACHELOR OF TECHNOLOGY and in the requrements it has:B.Tech. can I use a regex to make sure that even though the qualifications are spelled differently it still picks it up as the same? maybe something like:

        if(preg_match($pattern, $user_qualification) == preg_match($pattern,         $required_qualification)){
    //do something
    }

?

I get both qualification types(user and required) from database.

I have an idea of how regex works(only read a basic tut today).
a point in the right direction would be much apreciated.

updated my question....

You should be more specific... It's hard to tell something now. If you're not able to provide some data (due to your basic experience) you can try a better Regex Tutorial... you can type "regex tutorial" on Google and try the 4th result (from codeproject); it's quite good ;)

The | (or) operator can do that for you:

preg_match('%\b(b\.tech\.|bachelor of technology)\b%i', $subject);

How are you testing this? Is this something you are looking for in a free entry? If it is a specific field then there may be other options.

You should be more specific... It's hard to tell something now. If you're not able to provide some data (due to your basic experience) you can try a better Regex Tutorial... you can type "regex tutorial" on Google and try the 4th result (from codeproject); it's quite good ;)

Thanks will have a look.

The | (or) operator can do that for you:

preg_match('%\b(b.tech.|bachelor of technology)\b%i', $subject);

I also thought of something like that, using the or operator I mean, but it wont always be B.Tech, it can change to something like Bachelor's degree(B.A) then the example you gave would not work, would it?

Is this something you are looking for in a free entry?

yes it would be in a text box, can change it to a dropdown( would most likely be easier).

You would have to account for all possible options, no matter what road you take (except the dropdown).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.