About zero-width assertion does not support uncertain long-term problems












1















I am using the regular expression of python's re module to identify the 4 numbers in the string below this pattern:




The number of qualified individuals is 13553, company is 2500, The actual number of individuals joined is 7187,compny is 1722.




I was stuck when I used the zero-width assertion to identify the number after company is. I don't know how to identify the last number because there are two identical company is and (?<="some words") Expressions do not support indefinite length.



import re
content = "The number of qualified individuals is 13553, company is 2500, The actual number of individuals joined is 7187,company is 1722."

match_first = re.search("The actual.*d\b", content).group()
print(match_first)

match_content = re.search("(?<=companysiss)+d+", match_first).group()
print(match_content)


In fact, this method can also be matched, but it is cumbersome, I always feel that there is a way to match the last number with a single statement. It only matches the numbers, the others don't match, maybe because I learn regular expression. The time was too short, I spent a night studying regular expressions still didn't find a way. According to last night's understanding, it may be necessary to use recursive matching to solve it. I still need some time to finish it, but I think there must be a way.










share|improve this question

























  • I'm not sure I understand the question. If you only need to find all the digit sequences in a sentence, can't you use re.findall("d+", s)?

    – Kevin
    Nov 27 '18 at 17:04











  • Can you show us what have you tried so far?

    – MatAff
    Nov 27 '18 at 17:33











  • Thank you for your answer, because the above is only a part of the content, there are unrelated numbers in other content, so I need to use the only keywords in the "actual number of individuals joined" and "company is" keywords to lock this number. So that we won't recognize other useless numbers, and the numbers and other non-keywords may change, so we need to use such a troublesome way to lock, and I also want to use simple and easy to understand. The code is implemented.

    – aaron li
    Nov 27 '18 at 17:39











  • sorry, my time here is already two in the morning, I need to sleep first, tomorrow I will list the methods I have tried, thank you!

    – aaron li
    Nov 27 '18 at 17:42
















1















I am using the regular expression of python's re module to identify the 4 numbers in the string below this pattern:




The number of qualified individuals is 13553, company is 2500, The actual number of individuals joined is 7187,compny is 1722.




I was stuck when I used the zero-width assertion to identify the number after company is. I don't know how to identify the last number because there are two identical company is and (?<="some words") Expressions do not support indefinite length.



import re
content = "The number of qualified individuals is 13553, company is 2500, The actual number of individuals joined is 7187,company is 1722."

match_first = re.search("The actual.*d\b", content).group()
print(match_first)

match_content = re.search("(?<=companysiss)+d+", match_first).group()
print(match_content)


In fact, this method can also be matched, but it is cumbersome, I always feel that there is a way to match the last number with a single statement. It only matches the numbers, the others don't match, maybe because I learn regular expression. The time was too short, I spent a night studying regular expressions still didn't find a way. According to last night's understanding, it may be necessary to use recursive matching to solve it. I still need some time to finish it, but I think there must be a way.










share|improve this question

























  • I'm not sure I understand the question. If you only need to find all the digit sequences in a sentence, can't you use re.findall("d+", s)?

    – Kevin
    Nov 27 '18 at 17:04











  • Can you show us what have you tried so far?

    – MatAff
    Nov 27 '18 at 17:33











  • Thank you for your answer, because the above is only a part of the content, there are unrelated numbers in other content, so I need to use the only keywords in the "actual number of individuals joined" and "company is" keywords to lock this number. So that we won't recognize other useless numbers, and the numbers and other non-keywords may change, so we need to use such a troublesome way to lock, and I also want to use simple and easy to understand. The code is implemented.

    – aaron li
    Nov 27 '18 at 17:39











  • sorry, my time here is already two in the morning, I need to sleep first, tomorrow I will list the methods I have tried, thank you!

    – aaron li
    Nov 27 '18 at 17:42














1












1








1


0






I am using the regular expression of python's re module to identify the 4 numbers in the string below this pattern:




The number of qualified individuals is 13553, company is 2500, The actual number of individuals joined is 7187,compny is 1722.




I was stuck when I used the zero-width assertion to identify the number after company is. I don't know how to identify the last number because there are two identical company is and (?<="some words") Expressions do not support indefinite length.



import re
content = "The number of qualified individuals is 13553, company is 2500, The actual number of individuals joined is 7187,company is 1722."

match_first = re.search("The actual.*d\b", content).group()
print(match_first)

match_content = re.search("(?<=companysiss)+d+", match_first).group()
print(match_content)


In fact, this method can also be matched, but it is cumbersome, I always feel that there is a way to match the last number with a single statement. It only matches the numbers, the others don't match, maybe because I learn regular expression. The time was too short, I spent a night studying regular expressions still didn't find a way. According to last night's understanding, it may be necessary to use recursive matching to solve it. I still need some time to finish it, but I think there must be a way.










share|improve this question
















I am using the regular expression of python's re module to identify the 4 numbers in the string below this pattern:




The number of qualified individuals is 13553, company is 2500, The actual number of individuals joined is 7187,compny is 1722.




I was stuck when I used the zero-width assertion to identify the number after company is. I don't know how to identify the last number because there are two identical company is and (?<="some words") Expressions do not support indefinite length.



import re
content = "The number of qualified individuals is 13553, company is 2500, The actual number of individuals joined is 7187,company is 1722."

match_first = re.search("The actual.*d\b", content).group()
print(match_first)

match_content = re.search("(?<=companysiss)+d+", match_first).group()
print(match_content)


In fact, this method can also be matched, but it is cumbersome, I always feel that there is a way to match the last number with a single statement. It only matches the numbers, the others don't match, maybe because I learn regular expression. The time was too short, I spent a night studying regular expressions still didn't find a way. According to last night's understanding, it may be necessary to use recursive matching to solve it. I still need some time to finish it, but I think there must be a way.







python python-3.x






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 28 '18 at 6:04







aaron li

















asked Nov 27 '18 at 17:01









aaron liaaron li

62




62













  • I'm not sure I understand the question. If you only need to find all the digit sequences in a sentence, can't you use re.findall("d+", s)?

    – Kevin
    Nov 27 '18 at 17:04











  • Can you show us what have you tried so far?

    – MatAff
    Nov 27 '18 at 17:33











  • Thank you for your answer, because the above is only a part of the content, there are unrelated numbers in other content, so I need to use the only keywords in the "actual number of individuals joined" and "company is" keywords to lock this number. So that we won't recognize other useless numbers, and the numbers and other non-keywords may change, so we need to use such a troublesome way to lock, and I also want to use simple and easy to understand. The code is implemented.

    – aaron li
    Nov 27 '18 at 17:39











  • sorry, my time here is already two in the morning, I need to sleep first, tomorrow I will list the methods I have tried, thank you!

    – aaron li
    Nov 27 '18 at 17:42



















  • I'm not sure I understand the question. If you only need to find all the digit sequences in a sentence, can't you use re.findall("d+", s)?

    – Kevin
    Nov 27 '18 at 17:04











  • Can you show us what have you tried so far?

    – MatAff
    Nov 27 '18 at 17:33











  • Thank you for your answer, because the above is only a part of the content, there are unrelated numbers in other content, so I need to use the only keywords in the "actual number of individuals joined" and "company is" keywords to lock this number. So that we won't recognize other useless numbers, and the numbers and other non-keywords may change, so we need to use such a troublesome way to lock, and I also want to use simple and easy to understand. The code is implemented.

    – aaron li
    Nov 27 '18 at 17:39











  • sorry, my time here is already two in the morning, I need to sleep first, tomorrow I will list the methods I have tried, thank you!

    – aaron li
    Nov 27 '18 at 17:42

















I'm not sure I understand the question. If you only need to find all the digit sequences in a sentence, can't you use re.findall("d+", s)?

– Kevin
Nov 27 '18 at 17:04





I'm not sure I understand the question. If you only need to find all the digit sequences in a sentence, can't you use re.findall("d+", s)?

– Kevin
Nov 27 '18 at 17:04













Can you show us what have you tried so far?

– MatAff
Nov 27 '18 at 17:33





Can you show us what have you tried so far?

– MatAff
Nov 27 '18 at 17:33













Thank you for your answer, because the above is only a part of the content, there are unrelated numbers in other content, so I need to use the only keywords in the "actual number of individuals joined" and "company is" keywords to lock this number. So that we won't recognize other useless numbers, and the numbers and other non-keywords may change, so we need to use such a troublesome way to lock, and I also want to use simple and easy to understand. The code is implemented.

– aaron li
Nov 27 '18 at 17:39





Thank you for your answer, because the above is only a part of the content, there are unrelated numbers in other content, so I need to use the only keywords in the "actual number of individuals joined" and "company is" keywords to lock this number. So that we won't recognize other useless numbers, and the numbers and other non-keywords may change, so we need to use such a troublesome way to lock, and I also want to use simple and easy to understand. The code is implemented.

– aaron li
Nov 27 '18 at 17:39













sorry, my time here is already two in the morning, I need to sleep first, tomorrow I will list the methods I have tried, thank you!

– aaron li
Nov 27 '18 at 17:42





sorry, my time here is already two in the morning, I need to sleep first, tomorrow I will list the methods I have tried, thank you!

– aaron li
Nov 27 '18 at 17:42












0






active

oldest

votes











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/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
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53504631%2fabout-zero-width-assertion-does-not-support-uncertain-long-term-problems%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
















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%2f53504631%2fabout-zero-width-assertion-does-not-support-uncertain-long-term-problems%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

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

Calculate evaluation metrics using cross_val_predict sklearn

Insert data from modal to MySQL (multiple modal on website)