I'm trying to extract text and numeric patterns from a string. The strings are in the format of Account names, numbers, and some numbers.
1. Account Name 1 123456 10.256
2. Account & Na@me 2789 11\\456
3. Ac_NT N123ame 351462 12/453
The problem I’m facing is that the account name can have numbers within it, alpha/special characters/spaces within it.
When I write a pattern to extract the name, it greedily parses the spaces after the name and the account numbers after it. The only pattern I distinctly see in the data is that there is at least 3 spaces after the account name and before the account number.
So a pattern that catches everything before 3 spaces and then 3 or more digits after the spaces is what I’m looking for.
Would be great if someone can take a shot at this!
Solved! Go to Solution.
Hi @aravind_sk
Try this one
(.*?)\s{3,}(\d{3,})\s+(.*)
(.*?) extracts all non-greedy
\s{3,} 3 or more spaces
(\d{3,}) 3 or more digits
\s+ 1 or more spaces
(.*) rest of the line
giving this
Dan
Thanks Dan! This one worked. I'll have to learn more of non-greediness :)