Count substring if contains number?
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hello!
How can I count the number of substrings within a string, which contain numbers?
The following is what I am trying to get:
Address | Count |
Outing Park 69 Oswego St Apt 1R | 2 |
Outing Park 69 Oswego St Apt 1R | 2 |
Austin Street Apt 810 | 1 |
O RUBIN COURT APT D7 | 1 |
HAMBLIN CT 23 E MAIN ST APT 1B | 2 |
OLNEY ST APT 417 | 1 |
Thanks in advance!! 🙂
Solved! Go to Solution.
- Labels:
- Regex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
This works perfectly!
Could you please explain the expression?
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Sure thing!
REGEX_CountMatches([Address],"\s*(\d+)\s*")
- RegEx_CountMatch( is an expression that counts the matches with [String] as defined by "RegEx" pattern.
- "\s*" is zero or more (*) space character (\s) and "\d+" is one or more (+) digit characters (\d). So the pattern is a digit character with a space on one side or another before another digit character occurs.
This could use some more work because it has trouble with non-sequential digits since the spaces are optional.
Edit: This works.
REGEX_CountMatches([Address],"\s*(\w*\d+\w*)\s*")
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Nice!! thank you very much!!
