Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #80256
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'string.': 0.05; 'string': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'skip:$ 30': 0.09; 'snippet': 0.09; 'python': 0.11; 'advance!': 0.16; 'backslash,': 0.16; 'expressions,': 0.16; 'occurences': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'substitute': 0.16; ':-)': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'everyone,': 0.19; 'header:User-Agent:1': 0.23; 'header:X -Complaints-To:1': 0.27; 'correct': 0.29; "i'm": 0.30; 'anyone': 0.31; 'regular': 0.32; 'another': 0.32; 'could': 0.34; 'something': 0.35; 'but': 0.35; 'really': 0.36; 'next': 0.36; 'thanks': 0.36; 'handle': 0.38; 'to:addr:python-list': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'here': 0.66; 'skip:r 30': 0.69 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Eugene <hexumg@gmail.com> |
| Subject | Re: Regex substitution trouble |
| Date | Wed, 05 Nov 2014 13:44:35 +0300 |
| References | <8c1c1b7f-d121-4f3d-adf9-8262ddd8f102@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="ISO-8859-1" |
| Content-Transfer-Encoding | 7Bit |
| X-Gmane-NNTP-Posting-Host | 213.208.191.85 |
| User-Agent | KNode/4.14.2 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| 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> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.15485.1415187006.18130.python-list@python.org> (permalink) |
| Lines | 28 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1415187006 news.xs4all.nl 2922 [2001:888:2000:d::a6]:54729 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:80256 |
Show key headers only | View raw
massi_srb@msn.com wrote: > Hi everyone, > > I'm not really sure if this is the right place to ask about regular > expressions, but since I'm usin python I thought I could give a try :-) > Here is the problem, I'm trying to write a regex in order to substitute > all the occurences in the form $"somechars" with another string. This is > what I wrote: > > newstring = re.sub(ur"""(?u)(\$\"[\s\w]+\")""", subst, oldstring) > > This works pretty well, but it has a problem, I would need it also to > handle the case in which the internal string contains the double quotes, > but only if preceeded by a backslash, that is something like > $"somechars_with\\"doublequotes". Can anyone help me to correct it? > > Thanks in advance! Hi! Next snippet works for me: re.sub(r'\$"([\s\w]+(\\")*[\s\w]+)+"', 'noop', r'$"te\"sts\"tri\"ng"')
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Regex substitution trouble massi_srb@msn.com - 2014-10-28 04:02 -0700
Re: Regex substitution trouble Chris Angelico <rosuav@gmail.com> - 2014-10-28 22:24 +1100
Re: Regex substitution trouble massi_srb@msn.com - 2014-10-28 05:28 -0700
Re: Regex substitution trouble Chris Angelico <rosuav@gmail.com> - 2014-10-28 23:59 +1100
Re: Regex substitution trouble MRAB <python@mrabarnett.plus.com> - 2014-10-28 17:52 +0000
Re: Regex substitution trouble TP <wingusr@gmail.com> - 2014-10-28 06:25 -0700
Re: Regex substitution trouble Tim <jtim.arnold@gmail.com> - 2014-10-28 09:38 -0700
Re: Regex substitution trouble Cameron Simpson <cs@zip.com.au> - 2014-10-29 13:14 +1100
Re: Regex substitution trouble Eugene <hexumg@gmail.com> - 2014-11-05 13:44 +0300
csiph-web