Which regular expression string ignores single comment lines from a source code file?There must be a better...

When do you stop "pushing" a book?

Why was wildfire not used during the Battle of Winterfell?

What do "KAL." and "A.S." stand for in this inscription?

How to make a language evolve quickly?

Names of the Six Tastes

How can I avoid subordinates and coworkers leaving work until the last minute, then having no time for revisions?

Is it a good idea to copy a trader when investing?

What was the plan for an abort of the Enola Gay's mission to drop the atomic bomb?

Why does it take longer to fly from London to Xi'an than to Beijing

Why did they go to Dragonstone?

Why did Captain America age?

What is wrong with my code? RGB potentiometer

Program for finding longest run of zeros from a list of 100 random integers which are either 0 or 1

What does this quote in Small Gods refer to?

Why are low spin tetrahedral complexes so rare?

Why can't I prove summation identities without guessing?

How to handle DM constantly stealing everything from sleeping characters?

Cryptography and elliptic curves

Why do the non-leaf Nodes of Merkle tree need to be hashed?

Is ‘despite that’ right?

Succinct and gender-neutral Russian word for "writer"

Why use steam instead of just hot air?

Why is the Sun made of light elements only?

Is a vertical stabiliser needed for straight line flight in a glider?



Which regular expression string ignores single comment lines from a source code file?


There must be a better way to replace single newlines only?What is the definition of a regular expression?Change currency format to generic number using sedHow to remove multiple blank lines from a file?Regular expression that ignores certain charactersRegular expression not matching all possibilitiesRegular Expression ^$ not working on UNIX using grep commandGedit: How to insert backslash in search and replace regexHow to stop cat command from outputting file name if it's piped to another command?awk: Insert line after comments and imports in source file






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







0















I'm trying to parse a plain text file or a source code file for which I need to build a regular expression to detect single line comments. I'm trying the following one without success:



re = sprintf("^\%s.*\n$", Symbol)



Symbol is a variable that is passed to an AWK program and it should contain the particular character that marks the single line comment to be ignored.










share|improve this question







New contributor



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




















  • What are you trying to match with the n at the end, before the end of the line? Are you using a record separator (RS) that is not a newline?

    – Kusalananda
    2 hours ago













  • I was using the n the wrong way. Your question pointed me in the right direction. All I had to do was to remove the new line character from the RE and specify the record separator (RS) as n. Thank you very much!

    – ScutulatIum
    2 hours ago











  • The default value of RS is a newline, so you shouldn't have to set it at all.

    – Kusalananda
    2 hours ago











  • Right, thanks again.

    – ScutulatIum
    1 hour ago


















0















I'm trying to parse a plain text file or a source code file for which I need to build a regular expression to detect single line comments. I'm trying the following one without success:



re = sprintf("^\%s.*\n$", Symbol)



Symbol is a variable that is passed to an AWK program and it should contain the particular character that marks the single line comment to be ignored.










share|improve this question







New contributor



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




















  • What are you trying to match with the n at the end, before the end of the line? Are you using a record separator (RS) that is not a newline?

    – Kusalananda
    2 hours ago













  • I was using the n the wrong way. Your question pointed me in the right direction. All I had to do was to remove the new line character from the RE and specify the record separator (RS) as n. Thank you very much!

    – ScutulatIum
    2 hours ago











  • The default value of RS is a newline, so you shouldn't have to set it at all.

    – Kusalananda
    2 hours ago











  • Right, thanks again.

    – ScutulatIum
    1 hour ago














0












0








0








I'm trying to parse a plain text file or a source code file for which I need to build a regular expression to detect single line comments. I'm trying the following one without success:



re = sprintf("^\%s.*\n$", Symbol)



Symbol is a variable that is passed to an AWK program and it should contain the particular character that marks the single line comment to be ignored.










share|improve this question







New contributor



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











I'm trying to parse a plain text file or a source code file for which I need to build a regular expression to detect single line comments. I'm trying the following one without success:



re = sprintf("^\%s.*\n$", Symbol)



Symbol is a variable that is passed to an AWK program and it should contain the particular character that marks the single line comment to be ignored.







awk regular-expression






share|improve this question







New contributor



ScutulatIum 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



ScutulatIum 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



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








asked 3 hours ago









ScutulatIumScutulatIum

11




11




New contributor



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




New contributor




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















  • What are you trying to match with the n at the end, before the end of the line? Are you using a record separator (RS) that is not a newline?

    – Kusalananda
    2 hours ago













  • I was using the n the wrong way. Your question pointed me in the right direction. All I had to do was to remove the new line character from the RE and specify the record separator (RS) as n. Thank you very much!

    – ScutulatIum
    2 hours ago











  • The default value of RS is a newline, so you shouldn't have to set it at all.

    – Kusalananda
    2 hours ago











  • Right, thanks again.

    – ScutulatIum
    1 hour ago



















  • What are you trying to match with the n at the end, before the end of the line? Are you using a record separator (RS) that is not a newline?

    – Kusalananda
    2 hours ago













  • I was using the n the wrong way. Your question pointed me in the right direction. All I had to do was to remove the new line character from the RE and specify the record separator (RS) as n. Thank you very much!

    – ScutulatIum
    2 hours ago











  • The default value of RS is a newline, so you shouldn't have to set it at all.

    – Kusalananda
    2 hours ago











  • Right, thanks again.

    – ScutulatIum
    1 hour ago

















What are you trying to match with the n at the end, before the end of the line? Are you using a record separator (RS) that is not a newline?

– Kusalananda
2 hours ago







What are you trying to match with the n at the end, before the end of the line? Are you using a record separator (RS) that is not a newline?

– Kusalananda
2 hours ago















I was using the n the wrong way. Your question pointed me in the right direction. All I had to do was to remove the new line character from the RE and specify the record separator (RS) as n. Thank you very much!

– ScutulatIum
2 hours ago





I was using the n the wrong way. Your question pointed me in the right direction. All I had to do was to remove the new line character from the RE and specify the record separator (RS) as n. Thank you very much!

– ScutulatIum
2 hours ago













The default value of RS is a newline, so you shouldn't have to set it at all.

– Kusalananda
2 hours ago





The default value of RS is a newline, so you shouldn't have to set it at all.

– Kusalananda
2 hours ago













Right, thanks again.

– ScutulatIum
1 hour ago





Right, thanks again.

– ScutulatIum
1 hour 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
});


}
});






ScutulatIum 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%2f518075%2fwhich-regular-expression-string-ignores-single-comment-lines-from-a-source-code%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








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










draft saved

draft discarded


















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













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












ScutulatIum 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%2f518075%2fwhich-regular-expression-string-ignores-single-comment-lines-from-a-source-code%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°...