Take the 2-minute tour ×

What Python module can I use to extract certain chars from raw input? Example: user types in "1J1J"... I want Python to extract both the "J"s.

share|improve this question
Regular expressions? –  Benjamin Feb 2 '11 at 17:51
Can you provide me an example? –  Noah R Feb 2 '11 at 17:52
What do you want to do with the two JJs? –  user225312 Feb 2 '11 at 17:54
SO is not a free code writing service. Read the tutorial. Your question are overly inane and banal. –  SilentGhost Feb 2 '11 at 17:55
@SilentGhost let's remain polite... You don't have to answer if you don't like the question. Asking the poster to rephrase or be more precise might be a better idea. –  Benjamin Feb 2 '11 at 18:27

1 Answer 1

up vote 0 down vote accepted

result = raw_input("Enter some string: ")
print result.replace("J","")

Running this and giving input: 1J1J prints out:


Which is 1J1J but with the "J"s extracted

share|improve this answer
What is this supposed to mean? –  user225312 Feb 2 '11 at 18:02
The example doesn't mean anything... I'm applying it to a program I'm trying to write... thanks man! –  Noah R Feb 2 '11 at 18:04
Running that will extract the 'J's out of whatever raw input is provided. If the raw input given is "1J1J" it will extract the J's and print out "11". –  Cuga Feb 2 '11 at 18:05

Your Answer


