Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7446861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T12:27:02+00:00 2026-05-29T12:27:02+00:00

I am stumped by this one. I am just learning regular expressions and cannot

  • 0

I am stumped by this one. I am just learning regular expressions and cannot figure out why this will not return punctuation marks.

here is a piece of the text file the regex is parsing:

APRIL/NNP
is/VBZ
the/DT
cruellest/JJ
month/NN
,/,
breeding/VBG
Lilacs/NNP
out/RB
of/IN
the/DT
dead/JJ
land/NN

text = open_file.read()

grammarList = raw_input("Enter your grammar string: ");
tags = grammarList.split("^")


tags_pattern = r'\s+'.join(r"([\w\,\:\;\"\-\.]+)/{0}".format(re.escape(tag)) for tag in tags) + r"\b"
print tags_pattern

from re import findall
start_position = 0

for poem in poemList:
    start_position = text.find('<' + poem + '>', start_position)
    end_position = text.find('</' + poem + '>', start_position)

    searchtext = text [start_position:end_position]
    poemname = poem
    for oldname, newname in poemtitleswapList.items():
        poemname = poemname.replace(oldname, newname)

    print (poemname)
    print (findall(tags_pattern, searchtext))
    print ("\n")  

I thought that in the square brackets the “\,” would allow it to return a “,” but it is not working.

Any help would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T12:27:03+00:00Added an answer on May 29, 2026 at 12:27 pm

    After minimizing your example we have:

    re.findall(r"/\,\b", "/NN ,/, breeding/VBG Lilacs/NNP out/RB of/IN the/DT dead/JJ land/NN")
    

    And it does not match for obvious reasons: there is no beginning of the word immediately after the comma.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This one has me stumped. I'm clearly missing something, but I can't figure out
I'm a little stumped on this one and I'm also not still on 1.8
I'm really stumped on this incredibly simple mapping. It looks just like one of
I'm stumped on this one, or just to late at night to be thinking
I'm completely stumped on this one. I have three different lists that need to
So I'm stumped on this one. In Mac OS X there is an easy
I'm really stumped by this one! The StackFrame object ( MSDN Link ) has
I'm following a couple of Pythone exercises and I'm stumped at this one. #
This one has me stumped. I've got a java.sql.ResultSet and I'm pulling string values
This one has me stumped. <div id=container> <div id=store></div> <div id=contact></div> </div> I'm looking

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.