Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- l1 = ["abc", "abx", "bcd", "bcbdd", "f21fa", "f14"]
- print("Origin:\n",l1)
- l2 = list(filter(lambda x:re.match("ab|bc.*", x), l1))
- print("Filtered:\n",l2)
- > Origin:
- > ['abc', 'abx', 'bcd', 'bcbdd', 'f21fa', 'f14']
- > Filtered:
- > ['abc', 'abx', 'bcd', 'bcbdd']
Advertisement
Add Comment
Please, Sign In to add comment