Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #99220

Re: using re.split function

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From MRAB <python@mrabarnett.plus.com>
Newsgroups comp.lang.python
Subject Re: using re.split function
Date Sat, 21 Nov 2015 19:20:55 +0000
Lines 10
Message-ID <mailman.44.1448133667.2291.python-list@python.org> (permalink)
References <f810df9d-5691-467c-b212-7799dfdbb38d@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 7bit
X-Trace news.uni-berlin.de b77845/LTSIxLbw8dqhLBA4Sbq0uh2xumvK60bbl2QLA==
Return-Path <python@mrabarnett.plus.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'escape': 0.07; '"["': 0.09; 'indicates': 0.09; 'splitting': 0.09; 'string)': 0.09; 'subject:using': 0.09; 'python': 0.10; '"]"': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'received:192.168.1.4': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'string': 0.17; 'appears': 0.23; 'split': 0.23; 'second': 0.24; 'header:In-Reply- To:1': 0.24; 'header:User-Agent:1': 0.26; 'example': 0.26; 'conditions:': 0.29; 'didnt': 0.29; 'character': 0.29; 'normally': 0.30; 'set.': 0.35; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'received:192': 0.39; 'to:addr:python.org': 0.40
X-CM-Score 0.00
X-CNFS-Analysis v=2.1 cv=CvRCCSMD c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=EBOSESyhAAAA:8 a=IkcTkHD0fZMA:10 a=3LOA-L0sHOqdTqhbLIQA:9 a=QEXdDO2ut3YA:10 a=hh7FJ80c0FMA:10
X-AUTH mrabarnett@:2500
User-Agent Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0
In-Reply-To <f810df9d-5691-467c-b212-7799dfdbb38d@googlegroups.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:99220

Show key headers only | View raw


On 2015-11-21 18:49, david burstein wrote:
> im pretty new in python and i didnt get how to use the re.split function.
> for example if i have a string and i want to split it by two conditions:
> first one splitting when " [ " appears second one when "]" appears
>
re.split(r" \[ |\]", string)

You need to escape the "[" because it normally indicates the start of a
character set.

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

using re.split function david burstein <david007killer@gmail.com> - 2015-11-21 10:49 -0800
  Re: using re.split function MRAB <python@mrabarnett.plus.com> - 2015-11-21 19:20 +0000

csiph-web