Regex. Greedy and lazy quantifiers [duplicate]

Multi tool use
Multi tool use


.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








-1
















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"?










share|improve this question













marked as duplicate by Wiktor Stribiżew javascript
Users with the  javascript badge can single-handedly close javascript questions as duplicates and reopen them as needed.

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 use split? 'one\two\three.txt'.split('\')

    – Foo
    Nov 14 '18 at 5:04

















-1
















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"?










share|improve this question













marked as duplicate by Wiktor Stribiżew javascript
Users with the  javascript badge can single-handedly close javascript questions as duplicates and reopen them as needed.

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 use split? 'one\two\three.txt'.split('\')

    – Foo
    Nov 14 '18 at 5:04













-1












-1








-1


1







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"?










share|improve this question















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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 14 '18 at 4:59









ДмитрийДмитрий

1113




1113




marked as duplicate by Wiktor Stribiżew javascript
Users with the  javascript badge can single-handedly close javascript questions as duplicates and reopen them as needed.

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 javascript
Users with the  javascript badge can single-handedly close javascript questions as duplicates and reopen them as needed.

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 use split? 'one\two\three.txt'.split('\')

    – Foo
    Nov 14 '18 at 5:04












  • 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







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












1 Answer
1






active

oldest

votes


















0














You can use this regex: [w.]+?$

Details at regex101: https://regex101.com/r/n8HyiL/1

Or remove the ? it's still ok!






share|improve this answer





























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    You can use this regex: [w.]+?$

    Details at regex101: https://regex101.com/r/n8HyiL/1

    Or remove the ? it's still ok!






    share|improve this answer



























      0














      You can use this regex: [w.]+?$

      Details at regex101: https://regex101.com/r/n8HyiL/1

      Or remove the ? it's still ok!






      share|improve this answer

























        0












        0








        0







        You can use this regex: [w.]+?$

        Details at regex101: https://regex101.com/r/n8HyiL/1

        Or remove the ? it's still ok!






        share|improve this answer













        You can use this regex: [w.]+?$

        Details at regex101: https://regex101.com/r/n8HyiL/1

        Or remove the ? it's still ok!







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 14 '18 at 5:06









        protoprotoprotoproto

        1,013710




        1,013710















            E7gO epJR91a668F,FtrUZnN,fIGPz UA1P,Ssodyg2BMXArI pvgSS
            ur,EfAUWc,DoLFhzcBAYPB

            Popular posts from this blog

            Old paper Canadian currency

            𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

            ữḛḳṊẴ ẋ,Ẩṙ,ỹḛẪẠứụỿṞṦ,Ṉẍừ,ứ Ị,Ḵ,ṏ ṇỪḎḰṰọửḊ ṾḨḮữẑỶṑỗḮṣṉẃ Ữẩụ,ṓ,ḹẕḪḫỞṿḭ ỒṱṨẁṋṜ ḅẈ ṉ ứṀḱṑỒḵ,ḏ,ḊḖỹẊ Ẻḷổ,ṥ ẔḲẪụḣể Ṱ ḭỏựẶ Ồ Ṩ,ẂḿṡḾồ ỗṗṡịṞẤḵṽẃ ṸḒẄẘ,ủẞẵṦṟầṓế