How do i finda spl character in a string and return found one..?
Recommended Answers
Jump to PostYour question isn't very clear; can you provide a sample input/output for the use case in consideration?
Jump to PostShorter.
>>> strng = '1002-1004,1 1444' >>> re.findall(r'\W', strng) ['-', ',', ' ']
Or the same without regex.
>>> strng = '1002-1004,1 1444' >>> [c for c in strng if c in ['-', ',', ' ']] ['-', ',', ' ']
All 6 Replies
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
m_ishwar 13 Newbie Poster
krystosan 0 Junior Poster
krystosan 0 Junior Poster
snippsat 661 Master Poster
krystosan 0 Junior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.