I am in shell and I have this string: 12 BBQ ,45 rofl, 89 lol
12 BBQ ,45 rofl, 89 lol
Using the regexp: \\d+ (?=rofl), I want 45 as a result.
\\d+ (?=rofl)
45
you can use the shell(bash for example)
$ string="12 BBQ ,45 rofl, 89 lol" $ echo ${string% rofl*} 12 BBQ ,45 $ string=${string% rofl*} $ echo ${string##*,} 45