python - How to make Regex choose words seperately -
ok guys have string:
sockcooker!~shaz@rizon-ac7bdf2f.dynamic.dsl.as9105.com !~shaz@ privmsg #rizon :ohai. new here. registered 10 mins ago, have not got email. addy correct. email working fine. i want regex find !~shaz@ utilize r"!.+@" finds this
!~shaz@rizon-ac7bdf2f.dynamic.dsl.as9105.com !~shaz@ as remember.i want find them seperate ones , replace them letter..any help on 1 , yea if can give me regex tuts python i'd grateful :d
by default, quantifiers greedy in nature in sense, seek match much can. why regex matching till lastly @.
you can utilize reluctant quantifier (add ? after +) stop @ first @:
r"!.+?@" or can utilize negated character class, automatically stop @ first @:
r"![^@]+" choose whatever easier understand you.
python regex
No comments:
Post a Comment