Can't capture regex group? [duplicate]
Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
0
down vote
favorite
This question already has an answer here:
Why does my regular expression work in X but not in Y?
1 answer
I have Bash script below, trying to capture last digits of 'pingnet' but can not get a match. I verified in regex101 and my regex is correct:
pingnet="pingcount,site=DC,cur=200 total-up=988"
regex='(d+)$'
if [[ $pingnet =~ $regex ]]
then
echo "YES"
echo "$BASH_REMATCH[1]"
else
echo "NOT"
echo "$BASH_REMATCH[1]"
fi
The result of running script is NOT.
bash regular-expression
marked as duplicate by Jesse_b, slmâ¦
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Jul 19 at 20:26
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |Â
up vote
0
down vote
favorite
This question already has an answer here:
Why does my regular expression work in X but not in Y?
1 answer
I have Bash script below, trying to capture last digits of 'pingnet' but can not get a match. I verified in regex101 and my regex is correct:
pingnet="pingcount,site=DC,cur=200 total-up=988"
regex='(d+)$'
if [[ $pingnet =~ $regex ]]
then
echo "YES"
echo "$BASH_REMATCH[1]"
else
echo "NOT"
echo "$BASH_REMATCH[1]"
fi
The result of running script is NOT.
bash regular-expression
marked as duplicate by Jesse_b, slmâ¦
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Jul 19 at 20:26
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
2
d
doesn't work with bash's ERE, you need to use[0-9]
â Jesse_b
Jul 19 at 20:27
2
Maybe this will help: bash ERE regular expressions do not have thed
as explained in Bash =~ regex and https://regex101.com/
â Isaac
Jul 19 at 20:32
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
This question already has an answer here:
Why does my regular expression work in X but not in Y?
1 answer
I have Bash script below, trying to capture last digits of 'pingnet' but can not get a match. I verified in regex101 and my regex is correct:
pingnet="pingcount,site=DC,cur=200 total-up=988"
regex='(d+)$'
if [[ $pingnet =~ $regex ]]
then
echo "YES"
echo "$BASH_REMATCH[1]"
else
echo "NOT"
echo "$BASH_REMATCH[1]"
fi
The result of running script is NOT.
bash regular-expression
This question already has an answer here:
Why does my regular expression work in X but not in Y?
1 answer
I have Bash script below, trying to capture last digits of 'pingnet' but can not get a match. I verified in regex101 and my regex is correct:
pingnet="pingcount,site=DC,cur=200 total-up=988"
regex='(d+)$'
if [[ $pingnet =~ $regex ]]
then
echo "YES"
echo "$BASH_REMATCH[1]"
else
echo "NOT"
echo "$BASH_REMATCH[1]"
fi
The result of running script is NOT.
This question already has an answer here:
Why does my regular expression work in X but not in Y?
1 answer
bash regular-expression
edited Jul 19 at 20:26
slmâ¦
232k65479649
232k65479649
asked Jul 19 at 20:23
irom
184110
184110
marked as duplicate by Jesse_b, slmâ¦
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Jul 19 at 20:26
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Jesse_b, slmâ¦
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Jul 19 at 20:26
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
2
d
doesn't work with bash's ERE, you need to use[0-9]
â Jesse_b
Jul 19 at 20:27
2
Maybe this will help: bash ERE regular expressions do not have thed
as explained in Bash =~ regex and https://regex101.com/
â Isaac
Jul 19 at 20:32
add a comment |Â
2
d
doesn't work with bash's ERE, you need to use[0-9]
â Jesse_b
Jul 19 at 20:27
2
Maybe this will help: bash ERE regular expressions do not have thed
as explained in Bash =~ regex and https://regex101.com/
â Isaac
Jul 19 at 20:32
2
2
d
doesn't work with bash's ERE, you need to use [0-9]
â Jesse_b
Jul 19 at 20:27
d
doesn't work with bash's ERE, you need to use [0-9]
â Jesse_b
Jul 19 at 20:27
2
2
Maybe this will help: bash ERE regular expressions do not have the
d
as explained in Bash =~ regex and https://regex101.com/â Isaac
Jul 19 at 20:32
Maybe this will help: bash ERE regular expressions do not have the
d
as explained in Bash =~ regex and https://regex101.com/â Isaac
Jul 19 at 20:32
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
Bash's regex syntax does not recognize d
; use [[:digit:]]
instead:
pingnet="pingcount,site=DC,cur=200 total-up=988"
regex='([[:digit:]]+)$'
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
Bash's regex syntax does not recognize d
; use [[:digit:]]
instead:
pingnet="pingcount,site=DC,cur=200 total-up=988"
regex='([[:digit:]]+)$'
add a comment |Â
up vote
3
down vote
accepted
Bash's regex syntax does not recognize d
; use [[:digit:]]
instead:
pingnet="pingcount,site=DC,cur=200 total-up=988"
regex='([[:digit:]]+)$'
add a comment |Â
up vote
3
down vote
accepted
up vote
3
down vote
accepted
Bash's regex syntax does not recognize d
; use [[:digit:]]
instead:
pingnet="pingcount,site=DC,cur=200 total-up=988"
regex='([[:digit:]]+)$'
Bash's regex syntax does not recognize d
; use [[:digit:]]
instead:
pingnet="pingcount,site=DC,cur=200 total-up=988"
regex='([[:digit:]]+)$'
answered Jul 19 at 20:27
Jeff Schaller
30.8k846104
30.8k846104
add a comment |Â
add a comment |Â
2
d
doesn't work with bash's ERE, you need to use[0-9]
â Jesse_b
Jul 19 at 20:27
2
Maybe this will help: bash ERE regular expressions do not have the
d
as explained in Bash =~ regex and https://regex101.com/â Isaac
Jul 19 at 20:32