-1

Is it possible to do complex regex operations to retrieve name, role, designation in python? I have attached the pic for my requirement. enter image description here

lenz
  • 5,658
  • 5
  • 24
  • 44
PASUMPON V N
  • 1,186
  • 2
  • 10
  • 17

2 Answers2

0

No. You need actual Natural Language Processing for that.

lenz
  • 5,658
  • 5
  • 24
  • 44
0

The answer is Yes and No.

Regex is pattern matching. Anything that follows a specific pattern like phone number and url, yes you can extract that information using Regex with a great degree of accuracy.

Refer:

Regex for phone number

Regex for url

For roles & designation, if there is a manageable list that be used as anchors, it is still possible to use regex to retrieve this information.

Retrieving names can be tricky or simple depending on how uniformly you capture the data. I have shared a simple example that will look for 2 consecutive words with first letter capitalized separated by a space. However it might have to be tweaked to include cases that does not follow this pattern.

^([A-Z]\w+)\s([A-Z]\w+).*?

So in summary, I would say yes you can use regex to some extend but it may or may not be the best solution depending on what you are trying to achieve.

Community
  • 1
  • 1
WeShall
  • 409
  • 7
  • 20