Regex. Greedy and lazy quantifiers [duplicate]
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
This question already has an answer here:
Non-greedy match is still too greedy
2 answers
I have this string:
a = 'one\two\three.txt';
I want to get "three.txt". And this:
a.match(/\(.+?)$/)
Doesn't work. Why? How can I get "three.txt"?
javascript regex
marked as duplicate by Wiktor Stribiżew
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();
);
);
);
Nov 14 '18 at 8:42
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 |
This question already has an answer here:
Non-greedy match is still too greedy
2 answers
I have this string:
a = 'one\two\three.txt';
I want to get "three.txt". And this:
a.match(/\(.+?)$/)
Doesn't work. Why? How can I get "three.txt"?
javascript regex
marked as duplicate by Wiktor Stribiżew
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();
);
);
);
Nov 14 '18 at 8:42
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.
1
Doesn't work. Why?
Because it doesn't match.
– Foo
Nov 14 '18 at 5:01
So, why don't you usesplit
?'one\two\three.txt'.split('\')
– Foo
Nov 14 '18 at 5:04
add a comment |
This question already has an answer here:
Non-greedy match is still too greedy
2 answers
I have this string:
a = 'one\two\three.txt';
I want to get "three.txt". And this:
a.match(/\(.+?)$/)
Doesn't work. Why? How can I get "three.txt"?
javascript regex
This question already has an answer here:
Non-greedy match is still too greedy
2 answers
I have this string:
a = 'one\two\three.txt';
I want to get "three.txt". And this:
a.match(/\(.+?)$/)
Doesn't work. Why? How can I get "three.txt"?
This question already has an answer here:
Non-greedy match is still too greedy
2 answers
javascript regex
javascript regex
asked Nov 14 '18 at 4:59
ДмитрийДмитрий
1113
1113
marked as duplicate by Wiktor Stribiżew
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();
);
);
);
Nov 14 '18 at 8:42
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 Wiktor Stribiżew
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();
);
);
);
Nov 14 '18 at 8:42
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.
1
Doesn't work. Why?
Because it doesn't match.
– Foo
Nov 14 '18 at 5:01
So, why don't you usesplit
?'one\two\three.txt'.split('\')
– Foo
Nov 14 '18 at 5:04
add a comment |
1
Doesn't work. Why?
Because it doesn't match.
– Foo
Nov 14 '18 at 5:01
So, why don't you usesplit
?'one\two\three.txt'.split('\')
– Foo
Nov 14 '18 at 5:04
1
1
Doesn't work. Why?
Because it doesn't match.– Foo
Nov 14 '18 at 5:01
Doesn't work. Why?
Because it doesn't match.– Foo
Nov 14 '18 at 5:01
So, why don't you use
split
? 'one\two\three.txt'.split('\')
– Foo
Nov 14 '18 at 5:04
So, why don't you use
split
? 'one\two\three.txt'.split('\')
– Foo
Nov 14 '18 at 5:04
add a comment |
1 Answer
1
active
oldest
votes
You can use this regex: [w.]+?$
Details at regex101: https://regex101.com/r/n8HyiL/1
Or remove the ?
it's still ok!
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can use this regex: [w.]+?$
Details at regex101: https://regex101.com/r/n8HyiL/1
Or remove the ?
it's still ok!
add a comment |
You can use this regex: [w.]+?$
Details at regex101: https://regex101.com/r/n8HyiL/1
Or remove the ?
it's still ok!
add a comment |
You can use this regex: [w.]+?$
Details at regex101: https://regex101.com/r/n8HyiL/1
Or remove the ?
it's still ok!
You can use this regex: [w.]+?$
Details at regex101: https://regex101.com/r/n8HyiL/1
Or remove the ?
it's still ok!
answered Nov 14 '18 at 5:06
protoprotoprotoproto
1,013710
1,013710
add a comment |
add a comment |
1
Doesn't work. Why?
Because it doesn't match.– Foo
Nov 14 '18 at 5:01
So, why don't you use
split
?'one\two\three.txt'.split('\')
– Foo
Nov 14 '18 at 5:04