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 rextract to extract using a regular expression and reformat the result.
Example:
[$] echo "12 BBQ ,45 rofl, 89 lol" | ./rextract '[,]([\d]+) rofl' '${1}' 45