Why is regex [0-9]{0,2} not greedy in sed?extract part of string using sedWhy isn't sed using the extended...

How to tell if JDK is available from within running JVM?

How to not confuse readers with simultaneous events?

How long were the Apollo astronauts allowed to breathe 100% oxygen at 1 atmosphere continuously?

Which modern firearm should a time traveler bring to be easily reproducible for a historic civilization?

How many opportunity attacks can you make per turn before becoming exhausted?

Three Subway Escalators

Why is Google approaching my VPS machine?

What is this green alien supposed to be on the American covers of the "Hitchhiker's Guide to the Galaxy"?

I have found a mistake on someone's code published online: what is the protocol?

Why do jet engines sound louder on the ground than inside the aircraft?

How slow ( not zero) can a car engine run without hurting engine and saving on fuel

Why do the digits of a number squared follow a similar quotient?

Proof that every field is perfect???

Operation Unzalgo

Why aren't there any women super GMs?

Why are flying carpets banned while flying brooms are not?

Apex Legends stuck at 60 FPS (G-Sync 144hz monitor)

Batch processing/extracting raw data of one raster using one shapefile (with many polygons)?

Do Australia and New Zealand have a travel ban on Somalis (like Wikipedia says)?

Improving an O(N^2) function (all entities iterating over all other entities)

Why can't I hear fret buzz through the amp?

How to belay quickly ascending top-rope climbers?

Difference between class and struct in with regards to padding and inheritance

Is it possible to invoke "super" with less ambiguous results?



Why is regex [0-9]{0,2} not greedy in sed?


extract part of string using sedWhy isn't sed using the extended regex mode by default?SED command not replacing (working regex)Why does regex with \${ work with egrep, but not with sed?Regex - script check for allowed charactersUmask not workingExplain please sed scriptSed/awk Regex : XML feedWhy these two sed patterns don't give the same output?Sed regex: difference between -E and BRE (Sed & Awk 101 hacks)






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0















echo '123980925sriten34=ienat' | sed -e 's/^.*?([1-9][0-9]{0,2}+)([%=+-]).*/ 1 2 /'


is giving the result:



 4 =


i am expecting:



 34 =


what am i not understanding? thanks. :)



(oh and i even added the + and ? to make doubly sure, but afaik {0,2} should be greedy without the +...)










share|improve this question







New contributor



runrin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • perl -pe 's/^.*?([1-9][0-9]{0,2})([%=+-]).*/ $1 $2 /' is less annoying

    – user1133275
    35 mins ago






  • 1





    Isn't it more to do with the fact that the preceding .* is greedy?

    – steeldriver
    34 mins ago


















0















echo '123980925sriten34=ienat' | sed -e 's/^.*?([1-9][0-9]{0,2}+)([%=+-]).*/ 1 2 /'


is giving the result:



 4 =


i am expecting:



 34 =


what am i not understanding? thanks. :)



(oh and i even added the + and ? to make doubly sure, but afaik {0,2} should be greedy without the +...)










share|improve this question







New contributor



runrin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • perl -pe 's/^.*?([1-9][0-9]{0,2})([%=+-]).*/ $1 $2 /' is less annoying

    – user1133275
    35 mins ago






  • 1





    Isn't it more to do with the fact that the preceding .* is greedy?

    – steeldriver
    34 mins ago














0












0








0








echo '123980925sriten34=ienat' | sed -e 's/^.*?([1-9][0-9]{0,2}+)([%=+-]).*/ 1 2 /'


is giving the result:



 4 =


i am expecting:



 34 =


what am i not understanding? thanks. :)



(oh and i even added the + and ? to make doubly sure, but afaik {0,2} should be greedy without the +...)










share|improve this question







New contributor



runrin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











echo '123980925sriten34=ienat' | sed -e 's/^.*?([1-9][0-9]{0,2}+)([%=+-]).*/ 1 2 /'


is giving the result:



 4 =


i am expecting:



 34 =


what am i not understanding? thanks. :)



(oh and i even added the + and ? to make doubly sure, but afaik {0,2} should be greedy without the +...)







bash shell-script sed regular-expression






share|improve this question







New contributor



runrin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.










share|improve this question







New contributor



runrin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








share|improve this question




share|improve this question






New contributor



runrin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








asked 42 mins ago









runrinrunrin

1




1




New contributor



runrin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




New contributor




runrin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • perl -pe 's/^.*?([1-9][0-9]{0,2})([%=+-]).*/ $1 $2 /' is less annoying

    – user1133275
    35 mins ago






  • 1





    Isn't it more to do with the fact that the preceding .* is greedy?

    – steeldriver
    34 mins ago



















  • perl -pe 's/^.*?([1-9][0-9]{0,2})([%=+-]).*/ $1 $2 /' is less annoying

    – user1133275
    35 mins ago






  • 1





    Isn't it more to do with the fact that the preceding .* is greedy?

    – steeldriver
    34 mins ago

















perl -pe 's/^.*?([1-9][0-9]{0,2})([%=+-]).*/ $1 $2 /' is less annoying

– user1133275
35 mins ago





perl -pe 's/^.*?([1-9][0-9]{0,2})([%=+-]).*/ $1 $2 /' is less annoying

– user1133275
35 mins ago




1




1





Isn't it more to do with the fact that the preceding .* is greedy?

– steeldriver
34 mins ago





Isn't it more to do with the fact that the preceding .* is greedy?

– steeldriver
34 mins ago










0






active

oldest

votes














Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});






runrin is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f531098%2fwhy-is-regex-0-90-2-not-greedy-in-sed%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes








runrin is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















runrin is a new contributor. Be nice, and check out our Code of Conduct.













runrin is a new contributor. Be nice, and check out our Code of Conduct.












runrin is a new contributor. Be nice, and check out our Code of Conduct.
















Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f531098%2fwhy-is-regex-0-90-2-not-greedy-in-sed%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Hudson River Historic District Contents Geography History The district today Aesthetics Cultural...

The number designs the writing. Feandra Aversely Definition: The act of ingrafting a sprig or shoot of one...

Ayherre Geografie Demografie Externe links Navigatiemenu43° 23′ NB, 1° 15′ WL43° 23′ NB, 1°...