Solved

Looking for only the numbers that come before a certain word

  • 4 December 2022
  • 2 replies
  • 3 views

Badge +3

I have a dataset with a messy 'comments' column. I want to extract numbers from these comments, but only when the come before a ceratin word. For instance, a comment could be:

 

on januari 21, 16 boats passed

or

21 boats passed on januari 12 2017

 

I only want the numbers when they come beofre the word 'boat'. Is there a way to do that?

icon

Best answer by nielsgerrits 4 December 2022, 09:08

View original

2 replies

Userlevel 6
Badge +32

StringSearcher with regex should do this.

Badge +3

StringSearcher with regex should do this.

Thanks. I was struggling with the regex, but found it: \\d+(?=\\ boats)

Reply