Reputation: 1
Campus: Fairlane North
Building: testtesttest 5850 Mercury Dr
Floor: Floor 01 Common Area
Given the above test I want to extract "5850 Mercury"
I have tried /Building:.*(\d+\s\w+)/
Which gets me
0 Mercury
How do i get the rest of the digits? The number of digits can range from 1 to 6.
Thanks for the help.
Upvotes: 0
Views: 67
Reputation: 35208
Three methods.
Use non-greedy matching .*?
instead of greedy matching .*
/Building:.*?(\d+\s\w+)/
Impose a word boundary \b
to ensure you match the full number:
/Building:.*(\b\d+\s\w+)/
Change from the any character .
to non-digits \D
:
/Building:\D*(\d+\s\w+)/
Upvotes: 5