-4

I want to extract first 3 letters of the sentence which start with M and are followed by 2 digits.

If sentence is M30 INTHE SKY then output should be M30. IF sentence is THE INTHE SKY then answer should be np.nan(i.e. false as it didnot start with M)

soumya sharma
  • 35
  • 1
  • 5
  • 2
    This is trivial. Have you done any research? There are literally thousands of examples on this site of simple regular expressions like this. – Sean Bright Jun 17 '19 at 15:04
  • Have you tried solving this problem yourself yet? Note that pure regex can't necessarily generate an output which is not contained in the original input, so you might need a programming language to exactly solve your problem. – Tim Biegeleisen Jun 17 '19 at 15:05

1 Answers1

0

M\d{2}

  • M for literal M
  • \d to match one digit
  • {x} to match the previous token x times

If you do a search it will return the matched result; gives empty otherwise.

palvarez
  • 1,172
  • 2
  • 7
  • 16