RegEx to return number only from middle of text field
L
Laura Tuohy
started a topic
11 months ago
We have incoming data in a text field that looks like these examples:
HIKE: Hike name here - 3 Hikers
HIKE: Other hike name here - 12 Hikers
HIKE: 10th Anniversary Hike name - 1 Hikers
I would like to create a dictionary that pulls out the number of hikers so that it can be put in an RE attribute that takes only numbers. So, in the cases above:
3
12
1
A few notes:
The names of the hikes will vary in their length.
The number of hikers always follows a hyphen and then a space.
The word "Hikers" always follows the number of hikers (after a space), even for a single hiker.
The number of hikers may be single or double digit.
The names of hikes many even contain numbers themselves (like the 10th anniversary example) BUT I only want the number that appears after the hyphen and space and before "Hikers"
The closest I've gotten is to create a RegEx to return everything after the hyphen and space. So:
Replacement Value: --BLANK--
Values to Match on: .*(?<=- )
Which returns:
3 Hikers
12 Hikers
1 Hikers
But I need to have only a numerical value in this field. How do I also get rid of " Hikers"? I'm sure I need to take a different approach.
Laura Tuohy
We have incoming data in a text field that looks like these examples:
HIKE: Hike name here - 3 Hikers
HIKE: Other hike name here - 12 Hikers
HIKE: 10th Anniversary Hike name - 1 Hikers
I would like to create a dictionary that pulls out the number of hikers so that it can be put in an RE attribute that takes only numbers. So, in the cases above:
3
12
1
A few notes:
The closest I've gotten is to create a RegEx to return everything after the hyphen and space. So:
Replacement Value: --BLANK--
Values to Match on: .*(?<=- )
Which returns:
3 Hikers
12 Hikers
1 Hikers
But I need to have only a numerical value in this field. How do I also get rid of " Hikers"? I'm sure I need to take a different approach.