Source From Here
Question
I am in shell and I have this string:
Using the regexp: \d+ (?=rofl), I want 45 as a result. Is it correct to use regex to extract data from a string? The best I have done is to highlight the value in some of the online regex editor. Most of the time it remove the value from my string.
I am investigating expr, but all I get is syntax errors. How can I manage to extract 45 in a shell script?
How-To
You can do this with GNU grep's perl mode:
Question
I am in shell and I have this string:
Using the regexp: \d+ (?=rofl), I want 45 as a result. Is it correct to use regex to extract data from a string? The best I have done is to highlight the value in some of the online regex editor. Most of the time it remove the value from my string.
I am investigating expr, but all I get is syntax errors. How can I manage to extract 45 in a shell script?
How-To
You can do this with GNU grep's perl mode:
沒有留言:
張貼留言