Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.012 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'issue?': 0.09; 'output': 0.15; 'thu,': 0.15; 'subject:Regular': 0.16; 'wrote:': 0.16; 'string': 0.17; 'case.': 0.18; 'all,': 0.20; 'skip:" 30': 0.20; 'to:name:python-list@python.org': 0.20; 'fix': 0.21; 'am,': 0.23; '2015': 0.23; 'split': 0.23; 'header:In-Reply-To:1': 0.24; 'message-id:@mail.gmail.com': 0.28; 'fine': 0.29; 'problem': 0.33; 'received:google.com': 0.34; 'to:addr:python-list': 0.35; 'but': 0.36; 'subject:: ': 0.37; 'to:addr:python.org': 0.39; '9:36': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=VpmdntA0O3uFUFUso7kbNH3VcIK8877hv6/VG/8jGFM=; b=wnqsZBocEcmQ1bUVqQ25qajIb3hu5FG+Umpc7JUkZREfU1V3SgbNANoZld0sbFtPwo cGebtY730b4P1GeEetLNqwd7yMd4mXhg/Vjfd6Fx+tq/isakMfYh9xIddEU1umg3qNLP mnXKyvnqfOCXnTwTH0naf0NydduGI8Xx+h1ytzIfGCdEEq8cQjE3wodp+Zu7jIXQUkCe qkn5wyeC/sCROWl64yFHq3OFjBFAz1hRpSkuKI15zErk4xPhsPGRn3uu4rWLRE2GVb/l HtHbQLxIVnIsg5ysJxC+rUWKHXOXJA0lDV+zE/PznIYloBMVJv7zEQQ+F1Eh8jSnuvbS mpwg== MIME-Version: 1.0 X-Received: by 10.194.235.100 with SMTP id ul4mr7535825wjc.33.1433425439215; Thu, 04 Jun 2015 06:43:59 -0700 (PDT) In-Reply-To: References: Date: Thu, 4 Jun 2015 09:43:59 -0400 Subject: Re: Regular Expression From: Larry Martell To: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 12 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1433425441 news.xs4all.nl 2844 [2001:888:2000:d::a6]:44796 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:92051 On Thu, Jun 4, 2015 at 9:36 AM, Palpandi 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]