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


Groups > comp.lang.python > #99219 > unrolled thread

using re.split function

Started bydavid burstein <david007killer@gmail.com>
First post2015-11-21 10:49 -0800
Last post2015-11-21 19:20 +0000
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  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

#99219 — using re.split function

Fromdavid burstein <david007killer@gmail.com>
Date2015-11-21 10:49 -0800
Subjectusing re.split function
Message-ID<f810df9d-5691-467c-b212-7799dfdbb38d@googlegroups.com>
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

[toc] | [next] | [standalone]


#99220

FromMRAB <python@mrabarnett.plus.com>
Date2015-11-21 19:20 +0000
Message-ID<mailman.44.1448133667.2291.python-list@python.org>
In reply to#99219
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.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web