Regular Expressions Interview questions and answers for all language like PHP, Java, .net etc developer with lot of examples of complex search pattern and rewrite rules in Apache and .htaccess
| Questions : 1 | What is the mean of Regular Expressions ? What the use of Regular Expressions ? | |
| Answers : 1 |
Regular Expressions means we can say a pattern that one is an expression that specifies a set of strings. And there are lot of great use of these expressions like
|
|
| Questions : 2 | What the mean of different symbols like ^, $, * , + , ?, ., {},[] in Regular Expressions |
|
| Answers : 2 |
These symbols ^, $, * , + , ?, ., {},[] are very usefull like
|
|
| Questions : 3 | How we list which characters we DON'T want ?How to use backslash character | |
| Answer : 3 |
We can list which characters we DON'T want so just use a '^' as
the first symbol in a bracket expression (i.e., "%[^a-zA-Z]%" matches a string with a character that is not a letter between two percent signs). "^[a-zA-Z]": a string that starts with a letter; "[0-9]%": a string that has a single digit before a percent sign; ",[a-zA-Z0-9]$": a string that ends in a comma followed by an alphanumeric character. In order to be taken literally, you must escape the characters "^.[$()|*+?{\" with a backslash ('\'), as they have special meaning. On top of that, you must escape the backslash character itself in PHP3 strings, so, for instance, the regular expression "(\$|�)[0-9]+" would have the function call: ereg("(\\$|�)[0-9]+", $str) | |
| Questions : 4 | How you can validate email id use REG expression | |
| Answer : 4 | By using below reg expression we can validate email id ^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$ "^[_a-z0-9-]+": start with any underscore or alphanumeric one or more then one alfanumaric word "(\.[_a-z0-9-]+)*@":any dot(.) or alphanumeric zero times or more the zero and a @ sign "[a-z0-9-]+":one or more alphanumeric "(\.[a-z0-9-]+)*": zero or more dot alphanumeric or -(mins sign) "(\.[a-z]{2,5})$": End with two to 5 character may use dot (.) in that |
|