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

  • SEARCH
  • Home
  • 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 4000790
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:49:31+00:00 2026-05-20T07:49:31+00:00

I am trying to learn pyparsing. It sounds promising and something that would be

  • 0

I am trying to learn pyparsing. It sounds promising and something that would be fun to use for text processing. Anyhow, here is my question:

I have a list of course names. For example,

courselist = ["Project Based CALC",
           "CALCULUS I",
           "Calculus II",
           "Intermediate MICRO",
           "Intermediate CALCULUS advance",
           "UNIVERSITY PHYSICS"]

I want to extract courses from a list such as above that have to do with calculus. These are either courses that have the full word CALCULUS or abbreviation CALC. First, suppose that these words appear only in uppercase (there is one with lowercase in the above example; let us ignore that for the moment).

I have written the following code:

import pyparsing as pp

calc = pp.Literal("CALC")
for entry in courselist:
    if len(calc.searchString(entry)) >= 1:
        print entry
    else:
        pass

My first question is, whether there a better way of doing this using pyparsing?

Now the above misses Calculus II. I know I can catch that by defining calc as:

calc = pp.Literal("CALC") | pp.Literal("Calc")

But this will miss cAlc. Is there way to do specify the grammar such that all lower and upper case letters in CALC are matched.

Thank you for your help.

  • 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-20T07:49:31+00:00Added an answer on May 20, 2026 at 7:49 am
    calc = pp.CaselessLiteral('calc')
    for entry in courselist:
        if calc.searchString(entry, 1):
            print entry
    

    The effect is similar to:

    for entry in courselist:
        if 'calc' in entry.lower():
            print entry
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to learn how to write more dynamic web sites that use
Trying to learn jquery here so I took a regular javascript snippet that loops
Trying to learn backbone. In several applications that I've looked at (here is one
I'm trying to learn some XML Parsing here and I've been given some code
I am trying learn the use of lambda expressions and hence still struggling to
im trying to learn delegates and events in c#, i understand that an event
Trying to learn some F# and I've run into a couple of hangups. Here's
So, I'm trying to parse some simple C# code to learn how to use
Trying to learn PL/SQL with multimedia data. Can anyone please point out that from
I'm new in MVC3 and trying learn something. using Razor view engine. mysql database.

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.