Regular Expression

Larry Martell larry.martell at gmail.com
Thu Jun 4 09:43:59 EDT 2015


On Thu, Jun 4, 2015 at 9:36 AM, Palpandi <palpandi111 at gmail.com> wrote:
>
> Hi All,
>
> This is the case. To split "string2" from "string1_string2" I am using
> re.split('_', "string1_string2", 1)[1].
>
> It is working fine for string "string1_string2" and output as "string2". But actually the problem is that if a sting is "__string1_string2" and the output is "_string1_string2". It is wrong.
>
> How to fix this issue?

"__string1_string2".split('_')[-1]



More information about the Python-list mailing list