Mohsan
Mohsan

Reputation: 2509

extract lines using Regular Expression

I want to get following information from given text

Mohsan,Hasan    ADDRESS 123-456789
ABCD,EFGHIJKL   ADDRESS 123-456789
AB,XYZFGH   ADDRESS 123-456789

Get lines which have first name of 3-5 characters and last name of exact 5 characters

Upvotes: 0

Views: 66

Answers (2)

Toto
Toto

Reputation: 91373

If you want to be unicode compatible:

^\p{L}{3,5},\p{L}{5}\s

Upvotes: 0

Ωmega
Ωmega

Reputation: 43663

Use regex pattern

^[a-zA-Z]{3,5},[a-zA-Z]{5}\s

or in some environments/programming languages

^[a-zA-Z]{3,5},[a-zA-Z]{5}\\s

Upvotes: 2

Related Questions