How to extract specific line after regex matchHow to replace plain URLs with links?Match all occurrences of a regexRegular expression to match a line that doesn't contain a wordHow do you access the matched groups in a JavaScript regular expression?How to negate specific word in regex?RegEx match open tags except XHTML self-contained tagsRegex match entire words onlyHow to print matched regex pattern using awk?Check whether a string matches a regex in JSregex that matches all lines that contains a specific word <python>

Why do sellers care about down payments?

Can the card disintegrate destroy creatures with indestructible?

Planar regular languages

I asked for a graduate student position from a professor. He replied "welcome". What does that mean?

Can I conceal an antihero's insanity - and should I?

Sol Ⅲ = Earth: What is the origin of this planetary naming scheme?

What are uses of the byte after BRK instruction on 6502?

What is the mathematical notation for rounding a given number to the nearest integer?

How to find a value that ensures 70% of population is above it

Why did it become so much more expensive to start a university?

Is there a reliable way to hide/convey a message in vocal expressions (speech, song,...)

Should I leave the first authorship of our paper to the student who did the project whereas I solved it?

Does my opponent need to prove his creature has morph?

The Planck constant for mathematicians

Finding the number of digits of a given integer.

Writing a love interest for my hero

I was promised a work PC but still awaiting approval 3 months later so using my own laptop - Is it fair to ask employer for laptop insurance?

What is and what isn't ullage in rocket science?

Diffraction of a wave passing through double slits

A simple problem about Rule

Linear Programming with additional "if-then"/"Default to zero" constraints?

Bash, import output from command as command

Why did they ever make smaller than full-frame sensors?

Is the Dodge action perceptible to other characters?



How to extract specific line after regex match


How to replace plain URLs with links?Match all occurrences of a regexRegular expression to match a line that doesn't contain a wordHow do you access the matched groups in a JavaScript regular expression?How to negate specific word in regex?RegEx match open tags except XHTML self-contained tagsRegex match entire words onlyHow to print matched regex pattern using awk?Check whether a string matches a regex in JSregex that matches all lines that contains a specific word <python>






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








1















Given a keyword Product data sheet how can I extract 3rd line only after that match.



For example, given below data, output should be XB4BW84M5



Product data sheet
Characteristics
XB4BW84M5


I have tried (Product data sheet)rn(.*?)(^.*rn)3 but, that is to find something preceeded by 2 lines then the key word but, it extracts all 3 lines I need the 3rd only










share|improve this question





















  • 1





    What is your regex tool or language?

    – Tim Biegeleisen
    Mar 28 at 10:24

















1















Given a keyword Product data sheet how can I extract 3rd line only after that match.



For example, given below data, output should be XB4BW84M5



Product data sheet
Characteristics
XB4BW84M5


I have tried (Product data sheet)rn(.*?)(^.*rn)3 but, that is to find something preceeded by 2 lines then the key word but, it extracts all 3 lines I need the 3rd only










share|improve this question





















  • 1





    What is your regex tool or language?

    – Tim Biegeleisen
    Mar 28 at 10:24













1












1








1


1






Given a keyword Product data sheet how can I extract 3rd line only after that match.



For example, given below data, output should be XB4BW84M5



Product data sheet
Characteristics
XB4BW84M5


I have tried (Product data sheet)rn(.*?)(^.*rn)3 but, that is to find something preceeded by 2 lines then the key word but, it extracts all 3 lines I need the 3rd only










share|improve this question
















Given a keyword Product data sheet how can I extract 3rd line only after that match.



For example, given below data, output should be XB4BW84M5



Product data sheet
Characteristics
XB4BW84M5


I have tried (Product data sheet)rn(.*?)(^.*rn)3 but, that is to find something preceeded by 2 lines then the key word but, it extracts all 3 lines I need the 3rd only







regex






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 28 at 10:28









Michał Turczyn

20.8k13 gold badges24 silver badges42 bronze badges




20.8k13 gold badges24 silver badges42 bronze badges










asked Mar 28 at 10:21









ExorcismusExorcismus

80010 silver badges31 bronze badges




80010 silver badges31 bronze badges










  • 1





    What is your regex tool or language?

    – Tim Biegeleisen
    Mar 28 at 10:24












  • 1





    What is your regex tool or language?

    – Tim Biegeleisen
    Mar 28 at 10:24







1




1





What is your regex tool or language?

– Tim Biegeleisen
Mar 28 at 10:24





What is your regex tool or language?

– Tim Biegeleisen
Mar 28 at 10:24












1 Answer
1






active

oldest

votes


















4
















Use this pattern: (?<=Product data sheet)r?n.+r?n(.+)



Explanation:



(?<=Product data sheet) - assert that what's preceding is Product data sheet



If assertion is true, then it matches new line character with r?n, then matches whole line with .+, which is "match one or more of any characters", then again, in order to match newline I used r?n and then used (.+) to store in capturing group second line after desired string.



Demo






share|improve this answer






















  • 1





    This still captures the 2nd line.

    – Tim Biegeleisen
    Mar 28 at 10:26











  • @TimBiegeleisen But you can use capturing group to get the desired result

    – Michał Turczyn
    Mar 28 at 10:27











  • @TimBiegeleisen Then this would become impossible to achieve, as it would require positive lookbehind of variable length, which is only allowed in .NET. Moreover, what regex tools? I don't know any that doesn't support capturing group.

    – Michał Turczyn
    Mar 28 at 10:30







  • 1





    A wrong match is likely if third line doesn't exist. You'd better replace s* with r?n at least.

    – revo
    Mar 28 at 10:38






  • 1





    @fadytaher Using 1 as substitution pattern

    – Michał Turczyn
    Mar 28 at 11:50











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
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: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
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/4.0/"u003ecc by-sa 4.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
);



);














draft saved

draft discarded
















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55395178%2fhow-to-extract-specific-line-after-regex-match%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









4
















Use this pattern: (?<=Product data sheet)r?n.+r?n(.+)



Explanation:



(?<=Product data sheet) - assert that what's preceding is Product data sheet



If assertion is true, then it matches new line character with r?n, then matches whole line with .+, which is "match one or more of any characters", then again, in order to match newline I used r?n and then used (.+) to store in capturing group second line after desired string.



Demo






share|improve this answer






















  • 1





    This still captures the 2nd line.

    – Tim Biegeleisen
    Mar 28 at 10:26











  • @TimBiegeleisen But you can use capturing group to get the desired result

    – Michał Turczyn
    Mar 28 at 10:27











  • @TimBiegeleisen Then this would become impossible to achieve, as it would require positive lookbehind of variable length, which is only allowed in .NET. Moreover, what regex tools? I don't know any that doesn't support capturing group.

    – Michał Turczyn
    Mar 28 at 10:30







  • 1





    A wrong match is likely if third line doesn't exist. You'd better replace s* with r?n at least.

    – revo
    Mar 28 at 10:38






  • 1





    @fadytaher Using 1 as substitution pattern

    – Michał Turczyn
    Mar 28 at 11:50
















4
















Use this pattern: (?<=Product data sheet)r?n.+r?n(.+)



Explanation:



(?<=Product data sheet) - assert that what's preceding is Product data sheet



If assertion is true, then it matches new line character with r?n, then matches whole line with .+, which is "match one or more of any characters", then again, in order to match newline I used r?n and then used (.+) to store in capturing group second line after desired string.



Demo






share|improve this answer






















  • 1





    This still captures the 2nd line.

    – Tim Biegeleisen
    Mar 28 at 10:26











  • @TimBiegeleisen But you can use capturing group to get the desired result

    – Michał Turczyn
    Mar 28 at 10:27











  • @TimBiegeleisen Then this would become impossible to achieve, as it would require positive lookbehind of variable length, which is only allowed in .NET. Moreover, what regex tools? I don't know any that doesn't support capturing group.

    – Michał Turczyn
    Mar 28 at 10:30







  • 1





    A wrong match is likely if third line doesn't exist. You'd better replace s* with r?n at least.

    – revo
    Mar 28 at 10:38






  • 1





    @fadytaher Using 1 as substitution pattern

    – Michał Turczyn
    Mar 28 at 11:50














4














4










4









Use this pattern: (?<=Product data sheet)r?n.+r?n(.+)



Explanation:



(?<=Product data sheet) - assert that what's preceding is Product data sheet



If assertion is true, then it matches new line character with r?n, then matches whole line with .+, which is "match one or more of any characters", then again, in order to match newline I used r?n and then used (.+) to store in capturing group second line after desired string.



Demo






share|improve this answer















Use this pattern: (?<=Product data sheet)r?n.+r?n(.+)



Explanation:



(?<=Product data sheet) - assert that what's preceding is Product data sheet



If assertion is true, then it matches new line character with r?n, then matches whole line with .+, which is "match one or more of any characters", then again, in order to match newline I used r?n and then used (.+) to store in capturing group second line after desired string.



Demo







share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 28 at 10:41

























answered Mar 28 at 10:25









Michał TurczynMichał Turczyn

20.8k13 gold badges24 silver badges42 bronze badges




20.8k13 gold badges24 silver badges42 bronze badges










  • 1





    This still captures the 2nd line.

    – Tim Biegeleisen
    Mar 28 at 10:26











  • @TimBiegeleisen But you can use capturing group to get the desired result

    – Michał Turczyn
    Mar 28 at 10:27











  • @TimBiegeleisen Then this would become impossible to achieve, as it would require positive lookbehind of variable length, which is only allowed in .NET. Moreover, what regex tools? I don't know any that doesn't support capturing group.

    – Michał Turczyn
    Mar 28 at 10:30







  • 1





    A wrong match is likely if third line doesn't exist. You'd better replace s* with r?n at least.

    – revo
    Mar 28 at 10:38






  • 1





    @fadytaher Using 1 as substitution pattern

    – Michał Turczyn
    Mar 28 at 11:50













  • 1





    This still captures the 2nd line.

    – Tim Biegeleisen
    Mar 28 at 10:26











  • @TimBiegeleisen But you can use capturing group to get the desired result

    – Michał Turczyn
    Mar 28 at 10:27











  • @TimBiegeleisen Then this would become impossible to achieve, as it would require positive lookbehind of variable length, which is only allowed in .NET. Moreover, what regex tools? I don't know any that doesn't support capturing group.

    – Michał Turczyn
    Mar 28 at 10:30







  • 1





    A wrong match is likely if third line doesn't exist. You'd better replace s* with r?n at least.

    – revo
    Mar 28 at 10:38






  • 1





    @fadytaher Using 1 as substitution pattern

    – Michał Turczyn
    Mar 28 at 11:50








1




1





This still captures the 2nd line.

– Tim Biegeleisen
Mar 28 at 10:26





This still captures the 2nd line.

– Tim Biegeleisen
Mar 28 at 10:26













@TimBiegeleisen But you can use capturing group to get the desired result

– Michał Turczyn
Mar 28 at 10:27





@TimBiegeleisen But you can use capturing group to get the desired result

– Michał Turczyn
Mar 28 at 10:27













@TimBiegeleisen Then this would become impossible to achieve, as it would require positive lookbehind of variable length, which is only allowed in .NET. Moreover, what regex tools? I don't know any that doesn't support capturing group.

– Michał Turczyn
Mar 28 at 10:30






@TimBiegeleisen Then this would become impossible to achieve, as it would require positive lookbehind of variable length, which is only allowed in .NET. Moreover, what regex tools? I don't know any that doesn't support capturing group.

– Michał Turczyn
Mar 28 at 10:30





1




1





A wrong match is likely if third line doesn't exist. You'd better replace s* with r?n at least.

– revo
Mar 28 at 10:38





A wrong match is likely if third line doesn't exist. You'd better replace s* with r?n at least.

– revo
Mar 28 at 10:38




1




1





@fadytaher Using 1 as substitution pattern

– Michał Turczyn
Mar 28 at 11:50






@fadytaher Using 1 as substitution pattern

– Michał Turczyn
Mar 28 at 11:50









Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.




















draft saved

draft discarded















































Thanks for contributing an answer to Stack Overflow!


  • 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%2fstackoverflow.com%2fquestions%2f55395178%2fhow-to-extract-specific-line-after-regex-match%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

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해