• +91 9723535972
  • info@interviewmaterial.com

Regular Expressions Interview Questions and Answers

Regular Expressions Interview Questions and Answers

Question - 11 : - What is Greedy quantifiers * ,+,?     ?.

Answer - 11 : -

Greedy quantifiers trying to match as much as possible.

Question - 12 : - What is  Lazy quantifiers *? ,+?,??     ?.

Answer - 12 : -

Non Greedy or lazy quantifiers trying to match as possible minimum to satisfy condition

Question - 13 : - How do you see all text files from your system?

Answer - 13 : -

Go to search type *.txt 

meaning of pattern is to select all the files which has extension .txt

Question - 14 : - What is Backreferencing in Regular expressions?

Answer - 14 : -

Backreferencing is a feature of regular expressions, it is used to match new text that is same as matched earlier in the expression.

[0-9]+  match all the digits 9334

([0-9])\1+   match only 9334

\1 represent the match which was matched ([0-9]) 

Question - 15 : - What is lookaround in Regular expressions?

Answer - 15 : -

Generally regex works left to right but sometimes needs to process the text right to left.

Processing text right to left is called lookaround.
example : Needs to insert coma after three digits in cash 

12,345,678

Question - 16 : - How lookaround works in Regular expressions?

Answer - 16 : -

It is working like meta characters [\b][^][$] but they match the text based on positions with in the text.

Question - 17 : - Types of lookaround in Regular expressions?

Answer - 17 : -

we have two types of look around.

1) lookahead
2)lookbehind

Question - 18 : - What is lookahead in Regular expressions?

Answer - 18 : -

It is working towords to the right to see if match is exist 

Positive Lookahead:

  • If successful match to the right 
  • positive lookahead is specified with ( ?=...)
  • Ex: (?=\d)  successful where digit comes right 

Negative Lookahead:

  • If successful not match to the right 
  • positive lookahead is specified with ( ?!=...)

Question - 19 : - What is lookbehind in Regular expressions?

Answer - 19 : -

It is working towords to the left to see if match is exist 

Positive Lookbehind:

If match is successful match to the left

Positive lookbehind is specified with ( ?<=...)

Ex: (?<=\d)  successful where digit comes left


Negative Lookbehind:

If match is successful not match to the left

Negative lookbehind is specified with ( ?

Question - 20 : - What is the meaning "(?" in Regula expressions?

Answer - 20 : -

Open parenthesis sequence , They all begin with two characters like (? always perform some special functionality 

(?: ..) : group it but don't capture 

(?=...): look ahead 

(?<=...) : look behind


NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners