Home > Software engineering >  I want to take user input in regular expression in pandas
I want to take user input in regular expression in pandas

Time:02-15

Below is my code. python import pandas as pd

import re

text = "monotonous monumental Hello friday monoclonal"

mon = input('please write first three letters which you want to find ? ')

Number = int(input('please write how many number you want to extract after three letters ? '))

pattern = re.compile(mon '\w{Number}') #here in place of '{Number}' I want to use user input

match = pattern.findall(text)

print(match)

CodePudding user response:

import pandas as pd
import re
text = "monotonous monumental Hello friday monoclonal"
mon = input('please write first three letters which you want to find ? ')
pattern = re.compile(mon '\w{4}')#here in place of 'mon' I want to use user input
match = pattern.findall(text)
print(match)

This should work.

  • Related