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 6114765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:00:48+00:00 2026-05-23T15:00:48+00:00

this is my pseudocode but I dont see that regex has this function, at

  • 0

this is my pseudocode but I dont see that regex has this function, at least the way I am thinking of it:

#!/usr/bin/env python  
import sys
import os
import re

def main():
    wantedchars = re.match([ANY CHAR THAT APPEARS LESS THAN 8 TIMES], <text will be pasted here>)
    print wantedchars
if __name__=='__main__':
    main()

I would like to match any ascii char not just alphanumerics and less meaningful symbols.
like I want to match brackets and backslashes as well if they appear less than 8 times, the only thing I dont care to match/return are whitespace chars.
The reason for this whole thing and why I am not trying to pass the text as an argument is that it is for a one time thing that I will expand on later as part of a learning process I am trying to organize.
I mainly would like to know if I am going about this in the right way.
The other option that came to mind is to iterate over each char in the text and for each iteration increasing a counter for each unique char, then maybe printing the counters with the lowest values.

  • 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-23T15:00:48+00:00Added an answer on May 23, 2026 at 3:00 pm

    If the 8 chars aren’t contiguous, here is a way to do it using Counter (Python2.7+)

    >>> from collections import Counter
    
    # You can get the letters as a list...
    >>> [k for k,v in Counter("<text xx will xx be xx pasted xx here>").items() if v<8]
    ['a', 'b', 'e', 'd', 'i', 'h', 'l', 'p', 's', 'r', 't', 'w', '<', '>']
    
    # ...or a string
    >>> "".join(k for k,v in Counter("<text xx will xx be xx pasted xx here>").items() if v<8)
    'abedihlpsrtw<>'
    

    There’s a recipe for doing counters in older versions of Python too. Here’s one for 2.5/2.6

    >>> from collections import defaultdict
    >>> counter = defaultdict(int)
    >>> for c in "<text xx will xx be xx pasted xx here>":
    ...     counter[c]+=1
    ... 
    >>> "".join(k for k,v in counter.items() if v<8)
    'abedihlpsrtw<>'
    

    here’s one for python2.4

    >>> counter={}
    >>> for c in "<text xx will xx be xx pasted xx here>":
    ...     counter[c] = counter.get(c,0)+1
    ... 
    >>> "".join(k for k,v in counter.items() if v<8)
    'abedihlpsrtw<>'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this flavor of question has been asked multiple times, but I've spent
I am using pseudo-code here, but this is in JavaScript. With the most efficient
Is there any reason why this shouldn't work? [PseudoCode] main() { for (int i
This is a bit of a long shot, but if anyone can figure it
This is kinda oddball, but I was poking around with the GNU assembler today
Given this code snippet that can be readily pasted into Linqpad (or slightly modified
I'm wondering if anybody has run across something similar to this before. Some quick
Sorry, this is probably a duplicate question, but how can I iterate over a
In the following scenario, I was trying to see how to handle this code
Let's say I have this collection: val a = Array(Array(1,2,3,4,5),Array(4,5),Array(5),Array(1,2,6,7,8)) Is there a way

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.