0

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.

Edited by renierdbruyn: added more details

3
Contributors
6
Replies
15
Views
4 Years
Discussion Span
Last Post by pritaeas
0

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 ;)

Edited by sebastianGG

0

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.

0

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).

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.