It is good to see a nice small piece of code which we can run. Thank
you.
So there are a number of things to comment about in the code below;
comments inline under the relevant piece of code (we prefer the "inline
reply" style here, it reads like a conversation):
On 01Oct2020 15:15, Raju wrot
import re
import os
import sys
#word = "7 the world" # 7 The world
#word = "Brian'S" # Brian's
#word = "O'biran"# O'Brian
#word = "Stoke-On-Trent" # Stoke-on-Trent; here i need to lower the case of
middle word(i.e -On-)
def wordpattern(word):
output = ''
if re.match("^\d+|w*$",word):
On 01Oct2020 12:41, Raju wrote:
>I want to change the case on input string i was able to match using
>python regex but couldn't find the way to change the case.
>
>For example string:
>Input: 7Section Hello Jim
>output: 7Section hello Jim
>
>I was doing if statment with regex
>
>if re.match("(\d+
Il 03/09/20 22:16, Chris Angelico ha scritto:
Hmm. Have you considered using CSS to do this? Markdown is generally
fairly easy to style with CSS.
Yes, infact these are files where I'll insert a tag (in the example
, to show the errors find at a second revision due they are of
another kind, b
On Fri, Sep 4, 2020 at 5:36 AM Termoregolato wrote:
>
> Il 03/09/20 16:10, Termoregolato wrote:
>
> > I need to change every occurrence of a sequence between two chars
>
> Thanks to all for your replies, it's time to learn regular expressions,
> but now I've some valid pointers from you.
>
> The w
Il 03/09/20 16:10, Termoregolato wrote:
I need to change every occurrence of a sequence between two chars
Thanks to all for your replies, it's time to learn regular expressions,
but now I've some valid pointers from you.
The work I must do here, to explain, is to get some markdown files, an
Derp, sorry about the noise. I mistook this message for a similar
dialog over on the Vim mailing list.
For Python, you want
re.sub(r"%%(.*?)%%", r"\1", s, flags=re.S)
or put the flag inline
re.sub(r"(?s)%%(.*?)%%", r"\1", s)
-tim
On 2020-09-03 09:27, Tim Chase wrote:
> On 2020-09-03 16:1
On 2020-09-03 16:10, Termoregolato wrote:
> -- original
> This is the %%text that i must modify%%, on a line, %%but also
> on the others%% that are following
>
> I need to change to
>
> -- desidered
> This is the text that i must modify, on a line, but
> also on the others that are following
Sho
On Fri, Sep 4, 2020 at 12:16 AM Termoregolato wrote:
>
> Hi. I've on file, containing multiple lines, and I need to change every
> occurrence of a sequence between two chars, in this case "%%".
>
> -- original
> This is the %%text that i must modify%%, on a line, %%but also
> on the others%% that
On Mon, 2018-10-01 at 10:49 -0700, nanman3...@gmail.com wrote:
> I have a string like this:
>
> b'\tC:94.3%[S:89.9%,D:4.4%],F:1.7%,M:4.0%,n:1440\n'
>
> And I would like to extract the numbers corresponding to S,D,F and M in this
> string and convert them into an array like this:
>
> [ '89.9'
On 2018-10-01 18:49, nanman3...@gmail.com wrote:
I have a string like this:
b'\tC:94.3%[S:89.9%,D:4.4%],F:1.7%,M:4.0%,n:1440\n'
And I would like to extract the numbers corresponding to S,D,F and M in this
string and convert them into an array like this:
[ '89.9', '4.4', '1.7', '4.0']
Any he
On 2018-08-28 00:58, Malcolm wrote:
On 28/08/2018 7:09 AM, John Pote wrote:
On 26/08/2018 00:55, Malcolm wrote:
I am trying to understand why regex is not extracting all of the
characters between two delimiters.
The complete string is the xmp IFD data extracted from a .CR2 image
file.
I do
On 28/08/2018 7:09 AM, John Pote wrote:
On 26/08/2018 00:55, Malcolm wrote:
I am trying to understand why regex is not extracting all of the
characters between two delimiters.
The complete string is the xmp IFD data extracted from a .CR2 image
file.
I do have a work around, but it's messy a
On 26/08/2018 00:55, Malcolm wrote:
I am trying to understand why regex is not extracting all of the
characters between two delimiters.
The complete string is the xmp IFD data extracted from a .CR2 image file.
I do have a work around, but it's messy and possibly not future proof.
Do you mean f
On 08/25/2018 04:55 PM, Malcolm wrote:
I am trying to understand why regex is not extracting all of the
characters between two delimiters.
The complete string is the xmp IFD data extracted from a .CR2 image file.
I do have a work around, but it's messy and possibly not future proof.
Any insig
On 06/15/2018 12:37 PM, Ganesh Pal wrote:
Hey Friedrich,
The proposed solution worked nice , Thank you for the reply really
appreciate that
Only thing I think would need a review is if the assignment of the value
of one dictionary to the another dictionary if is done correctly ( lines
17
On Wed, Jun 13, 2018 at 4:08 AM, Ganesh Pal wrote:
> Hi Team,
>
> I wanted to parse a file and extract few feilds that are present after "="
> in a text file .
>
>
> Example , form the below line I need to extract the values present after
> --struct =, --loc=, --size= and --log_file=
>
> Sample
>
{'struct': 'data_block', 'log_file': '/var/1000111/test18.log', 'loc':
> '0', 'size': '8'}
>
>
MARB, as usual the solution you you look nice, Thanks for the excellent
solutions
>>> regex = re.compile (r"--(struct|loc|size|mirror|l
og_file)\s*=\s*([^\s]+)")
>>> regex.findall (line)
[('struct
On 06/13/2018 07:32 PM, Ganesh Pal wrote:
On Wed, Jun 13, 2018 at 5:59 PM, Rhodri James wrote:
On 13/06/18 09:08, Ganesh Pal wrote:
Hi Team,
I wanted to parse a file and extract few feilds that are present after "="
in a text file .
Example , form the below line I need to extract t
On 2018-06-13 18:32, Ganesh Pal wrote:
On Wed, Jun 13, 2018 at 5:59 PM, Rhodri James wrote:
On 13/06/18 09:08, Ganesh Pal wrote:
Hi Team,
I wanted to parse a file and extract few feilds that are present after "="
in a text file .
Example , form the below line I need to extract the valu
On Wed, Jun 13, 2018 at 5:59 PM, Rhodri James wrote:
> On 13/06/18 09:08, Ganesh Pal wrote:
>
>> Hi Team,
>>
>> I wanted to parse a file and extract few feilds that are present after "="
>> in a text file .
>>
>>
>> Example , form the below line I need to extract the values present after
>> --
On 13/06/18 09:08, Ganesh Pal wrote:
Hi Team,
I wanted to parse a file and extract few feilds that are present after "="
in a text file .
Example , form the below line I need to extract the values present after
--struct =, --loc=, --size= and --log_file=
Sample input
line = '06/12/2018 11
On Wednesday, 18 April 2018 19:34:37 UTC+2, MRAB wrote:
> > Hi,
> >
> > I have a sql query in which all variables declared as :variable should be
> > changed to ${variable}.
> >
> > for example this sql:
> >
> > select *
> > from table
> > where ":x" = "1" and :y=2
> > and field in (:string)
On 2018-04-18 08:25, zljubi...@gmail.com wrote:
Hi,
I have a sql query in which all variables declared as :variable should be
changed to ${variable}.
for example this sql:
select *
from table
where ":x" = "1" and :y=2
and field in (:string)
and time between :from and :to
should be tran
On 4/5/2018 11:03 AM, Steven D'Aprano wrote:
On Thu, 05 Apr 2018 14:09:23 +0530, Prahallad Achar wrote:
I would like to match set of lines from the below data. this data comes
from one of the network
Good grief! You don't need to post your entire data set! We don't need or
want to see hundred
On Thu, 05 Apr 2018 14:09:23 +0530, Prahallad Achar wrote:
> Hello,
> I would like to match set of lines from the below data. this data comes
> from one of the network
Good grief! You don't need to post your entire data set! We don't need or
want to see hundreds of lines.
Cut your data down to
Thanks a lot Antoon.
On Fri, Mar 30, 2018 at 2:51 PM, Antoon Pardon wrote:
> On 30-03-18 08:16, Iranna Mathapati wrote:
> > Hi Team,
> >
> >
> > how to achieve fallowing expected output?
> >
> > str_output= """
> >
> > MOD1 memory : 2 valid1790 free
> > MOD2 me
On 30-03-18 08:16, Iranna Mathapati wrote:
> Hi Team,
>
>
> how to achieve fallowing expected output?
>
> str_output= """
>
> MOD1 memory : 2 valid1790 free
> MOD2 memory : 128 valid 128 free
> UDP Aware *MEMR*
On 30Mar2018 11:46, Iranna Mathapati wrote:
how to achieve fallowing expected output?
str_output= """
MOD1 memory : 2 valid1790 free
MOD2 memory : 128 valid 128 free
UDP Aware *MEMR*: 0 valid 0 free *
Hi Cameron.
str_output= """
MOD1 memory: 2 valid1790 free
MOD2 memory: 128 valid 128 free
UDP Aware MEMR : 0 valid0 free
*MEMR* : 21 valid 491 free
Feature XYZ
Hello,
this question also came up there:
https://python-forum.io/Thread-Working-with-Dict-Object
Greetings
Andre
--
https://mail.python.org/mailman/listinfo/python-list
On 13/02/18 18:08, Stanley Denman wrote:
On Tuesday, February 13, 2018 at 9:41:14 AM UTC-6, Mark Lawrence wrote:
On 13/02/18 13:11, Stanley Denman wrote:
I am trying to performance a regex on a "string" of text that python isinstance
is telling me is a dictionary. When I run the code I get th
On Tuesday, February 13, 2018 at 9:41:14 AM UTC-6, Mark Lawrence wrote:
> On 13/02/18 13:11, Stanley Denman wrote:
> > I am trying to performance a regex on a "string" of text that python
> > isinstance is telling me is a dictionary. When I run the code I get the
> > following error:
> >
> > {'
On Tue, 13 Feb 2018 13:53:04 +, Mark Lawrence wrote:
> Was the string methods solution that I gave a week or so ago so bad that
> you still think that you need a regex to solve this?
Sometimes regexes are needed, but often Jamie Zawinski is right:
Some people, when confronted with a prob
On Tue, 13 Feb 2018 05:11:20 -0800, Stanley Denman wrote:
> I am trying to performance a regex on a "string" of text that python
> isinstance is telling me is a dictionary.
Please believe Python when it tells you that something is a dictionary.
Trust me, the interpreter knows. It doesn't matter
On 13/02/18 13:11, Stanley Denman wrote:
I am trying to performance a regex on a "string" of text that python isinstance
is telling me is a dictionary. When I run the code I get the following error:
{'/Title': '1F: Progress Notes Src.: MILANI, JOHN C Tmt. Dt.: 05/12/2014 -
05/28/2014 (9 p
On Tue, 13 Feb 2018 13:42:08 +, Rhodri James wrote:
> On 13/02/18 13:11, Stanley Denman wrote:
>> I am trying to performance a regex on a "string" of text that python
>> isinstance is telling me is a dictionary. When I run the code I get
>> the following error:
>>
>> {'/Title': '1F: Progres
On 13/02/18 13:11, Stanley Denman wrote:
I am trying to performance a regex on a "string" of text that python isinstance
is telling me is a dictionary. When I run the code I get the following error:
{'/Title': '1F: Progress Notes Src.: MILANI, JOHN C Tmt. Dt.: 05/12/2014 -
05/28/2014 (9 p
Hi Stanley,
Le 2018-02-13 à 08:11, Stanley Denman a écrit :
x=MyRegex.findall(MyDict)
How about:
x = [MyRegex.findall(item) for item in MyDict]
Etienne
--
Etienne Robillard
tkad...@yandex.com
https://www.isotopesoftware.ca/
--
https://mail.python.org/mailman/listinfo/python-list
Big thank you to everyone who offered their help!
On 03/06/2016 11:38 PM, Fillmore wrote:
--
https://mail.python.org/mailman/listinfo/python-list
Fillmore wrote:
>
> Hi, I'm trying to move away from Perl and go to Python.
> Regex seems to bethe hardest challenge so far.
>
> Perl:
>
> while () {
> if (/(\d+)\t(.+)$/) {
> print $1." - ". $2."\n";
> }
> }
>
> into python
>
> pattern = re.compile(r"(\d+)\t(.+)$")
> with open(fiel
Also for regex hacking:
Try with findall before using match/search
--
https://mail.python.org/mailman/listinfo/python-list
Also for regex hacking:
Try with findall before using match/search
--
https://mail.python.org/mailman/listinfo/python-list
On 3/6/2016 11:38 PM, Fillmore wrote:
Hi, I'm trying to move away from Perl and go to Python.
Regex seems to bethe hardest challenge so far.
Perl:
while () {
if (/(\d+)\t(.+)$/) {
print $1." - ". $2."\n";
}
}
into python
pattern = re.compile(r"(\d+)\t(.+)$")
with open(fields_I
On Mon, Mar 7, 2016 at 3:38 PM, Fillmore wrote:
> pattern = re.compile(r"(\d+)\t(.+)$")
> with open(fields_Indexfile,mode="rt",encoding='utf-8') as headerfile:
> for line in headerfile:
> #sys.stdout.write(line)
> m = pattern.match(line)
> print(m.group(0))
> header
MRAB writes:
> On 2015-08-18 22:55, Ben Bacarisse wrote:
>> Neal Becker writes:
>>
>>> Trying regex 2015.07.19
>>>
>>> I'd like to match recursive parenthesized expressions, with groups such that
>>> '(a(b)c)'
>>>
>>> would give
>>> group(0) -> '(a(b)c)'
>>> group(1) -> '(b)'
>>>
>>> but that's
On 2015-08-18 22:55, Ben Bacarisse wrote:
Neal Becker writes:
Trying regex 2015.07.19
I'd like to match recursive parenthesized expressions, with groups such that
'(a(b)c)'
would give
group(0) -> '(a(b)c)'
group(1) -> '(b)'
but that's not what I get
import regex
#r = r'\((?>[^()]|(?R))*\)
Neal Becker writes:
> Trying regex 2015.07.19
>
> I'd like to match recursive parenthesized expressions, with groups such that
> '(a(b)c)'
>
> would give
> group(0) -> '(a(b)c)'
> group(1) -> '(b)'
>
> but that's not what I get
>
> import regex
>
> #r = r'\((?>[^()]|(?R))*\)'
> r = r'\(([^()]|(?
On 2015-08-18 15:25, Neal Becker wrote:
Trying regex 2015.07.19
I'd like to match recursive parenthesized expressions, with groups such that
'(a(b)c)'
would give
group(0) -> '(a(b)c)'
group(1) -> '(b)'
but that's not what I get
import regex
#r = r'\((?>[^()]|(?R))*\)'
r = r'\(([^()]|(?R))*\)
On 8/18/2015 10:25 AM, Neal Becker wrote:
Trying regex 2015.07.19
I'd like to match recursive parenthesized expressions, with groups such that
'(a(b)c)'
Extended regular expressions can only match strings in extended regular
languages. General nested expressions are too general for that. Yo
On Wed, 25 Mar 2015 14:19:39 -0700, Gregg Dotoli wrote:
> On Wednesday, March 25, 2015 at 4:36:01 PM UTC-4, Denis McMahon wrote:
>> On Tue, 24 Mar 2015 11:13:41 -0700, gdotoli wrote:
>>
>> > I am creating a tool to search a filesystem for one simple string.
>>
>> man grep
>>
>> STOP! REINVENTIN
On 3/25/2015 7:10 PM, Steven D'Aprano wrote:
Does Windows shell have grep? How about Powershell?
No. I just use Idle's grep (Find in Files). And I generally would even
if Command Prompt did have grep. Idle's has the nice feature that
output goes in an Output Window, with each line found p
On 25/03/2015 23:10, Steven D'Aprano wrote:
On Thu, 26 Mar 2015 08:19 am, Gregg Dotoli wrote:
Grep is regular expressions. If I'm using Python, I'll use the Python
modules. Silly
It very well may be silly.
You're using Python regular expressions because you're using Python. Why are
you using
On Thu, 26 Mar 2015 08:19 am, Gregg Dotoli wrote:
> Grep is regular expressions. If I'm using Python, I'll use the Python
> modules. Silly
It very well may be silly.
You're using Python regular expressions because you're using Python. Why are
you using Python? Early in this thread you said
"H
On 25/03/2015 21:19, Gregg Dotoli wrote:
Grep is regular expressions. If I'm using Python, I'll use the Python modules.
Silly
Gregg
Clear as mud, and please don't top post.
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrenc
Grep is regular expressions. If I'm using Python, I'll use the Python modules.
Silly
Gregg
On Wednesday, March 25, 2015 at 4:36:01 PM UTC-4, Denis McMahon wrote:
> On Tue, 24 Mar 2015 11:13:41 -0700, gdotoli wrote:
>
> > I am creating a tool to search a filesystem for one simple string.
>
> man
On Tue, 24 Mar 2015 11:13:41 -0700, gdotoli wrote:
> I am creating a tool to search a filesystem for one simple string.
man grep
STOP! REINVENTING! THE! WHEEL!
Your new wheel will invariably be slower and less efficient than the old
one.
--
Denis McMahon, denismfmcma...@gmail.com
--
https:/
No worries Steven,
Thanks to ALL on this thread.
Gregg
On Tuesday, March 24, 2015 at 9:43:58 PM UTC-4, Steven D'Aprano wrote:
> On Wed, 25 Mar 2015 05:13 am, gdot...@gmail.com wrote:
>
> > The error is:
> >
> > SyntaxError: Missing parentheses in call to 'print'
>
>
> I cannot imagine how
On Wed, 25 Mar 2015 05:13 am, gdot...@gmail.com wrote:
> The error is:
>
> SyntaxError: Missing parentheses in call to 'print'
I cannot imagine how the message could be more explicit: the call to print
is missing parentheses. If you're not going to read the error messages you
are given, you are
Here you go. Windows shell was easier!!!
for /f %a in (c:\gonow) do echo %a | c:\Python34\python c:\python34\unopy.py %a
Now I can use any regex pattern, I need.
On Tuesday, March 24, 2015 at 3:54:25 PM UTC-4, Rob Gaddi wrote:
> On Tue, 24 Mar 2015 12:43:38 -0700, Gregg Dotoli wrote:
>
> > [c
On 3/24/2015 2:13 PM, gdot...@gmail.com wrote:
I am creating a tool to search a filesystem for one simple string.
I cannot get the syntax correct.
Thank you in advance for your help.
import sys
import re
import os
path='/'
viewfiles=os.listdir(path)
listdir is not recursive, so this code will
On Tue, 24 Mar 2015 12:43:38 -0700, Gregg Dotoli wrote:
> [context snipped due to top posting]
>
> All I need is a loop, should I bag Python and use a simple shell for
loop?
Honestly, yes. You're not even using a regular expression, just a fixed
string you're trying to search for. You can do
Le 24/03/2015 20:22, Gregg Dotoli a écrit :
Thank you! But
The print error is gone, but now the script quickly finishes and doesnt walk
the OS tree or search.
Gregg
On Tuesday, March 24, 2015 at 2:14:32 PM UTC-4, Gregg Dotoli wrote:
I am creating a tool to search a filesystem for one simple
This works fine , but I have to pipe the filename to the script python stool
I am creating a tool to search a filesystem for one simple string.
> I cannot get the syntax correct.
> Thank you in advance for your help.
>
> import sys
> import re
> import os
> path='/'
> viewfiles=os.listdir(path)
On Tue, 24 Mar 2015 12:10:24 -0700, Gregg Dotoli wrote:
>
> Thank you Gary, that got rid of the error, but now there is no tree
> walk, it runs and immediatley finishes. I just need to grep each file. I
> have this working with the windows "for /r %a and redirecting that to
> Python, but want to u
On Tue, Mar 24, 2015 at 2:22 PM, Gregg Dotoli wrote:
> The print error is gone, but now the script quickly finishes and doesnt
> walk
> the OS tree or search.
>
You need to walk the directory tree recursively. Take a look at os.walk().
Skip
--
https://mail.python.org/mailman/listinfo/python-li
Le 24/03/2015 20:38, Vincent Vande Vyvre a écrit :
Le 24/03/2015 20:22, Gregg Dotoli a écrit :
Thank you! But
The print error is gone, but now the script quickly finishes and
doesnt walk
the OS tree or search.
Gregg
On Tuesday, March 24, 2015 at 2:14:32 PM UTC-4, Gregg Dotoli wrote:
I am
Thank you! But
The print error is gone, but now the script quickly finishes and doesnt walk
the OS tree or search.
Gregg
On Tuesday, March 24, 2015 at 2:14:32 PM UTC-4, Gregg Dotoli wrote:
> I am creating a tool to search a filesystem for one simple string.
> I cannot get the syntax correct.
Thank you Gary, that got rid of the error, but now there is no tree walk, it
runs and immediatley finishes. I just need to grep each file. I have this
working with the windows "for /r %a and redirecting that to Python, but want to
use Python only. I do have dummy files with the regex string.
Th
On 03/24/2015 11:13 AM, gdot...@gmail.com wrote:
I am creating a tool to search a filesystem for one simple string.
I cannot get the syntax correct.
Thank you in advance for your help.
import sys
import re
import os
path='/'
viewfiles=os.listdir(path)
for allfiles in viewfiles:
file= os.pat
On Tue, Mar 24, 2015 at 1:13 PM, wrote:
> SyntaxError: Missing parentheses in call to 'print'
It appears you are attempting to use a Python 2.x print statement with
Python 3.x Try changing the last line to
print(line.rstrip())
Skip
--
https://mail.python.org/mailman/listinfo/python-list
Larry Martell wrote:
> I need to remove all trailing zeros to the right of the decimal point,
> but leave one zero if it's whole number.
def strip_zero(s):
if '.' not in s:
return s
s = s.rstrip('0')
if s.endswith('.'):
s += '0'
return s
And in use:
py> strip_
On 13Mar2015 12:05, Larry Martell wrote:
I need to remove all trailing zeros to the right of the decimal point,
but leave one zero if it's whole number. For example, if I have this:
14S,5.,4.5686274500,3.7272727272727271,3.3947368421052630,5.7307692307692308,5.75471698113207
On Fri, Mar 13, 2015 at 1:29 PM, MRAB wrote:
> On 2015-03-13 16:05, Larry Martell wrote:
>>
>> I need to remove all trailing zeros to the right of the decimal point,
>> but leave one zero if it's whole number. For example, if I have this:
>>
>>
>> 14S,5.,4.5686274500,3.72727272
On 2015-03-13 12:05, Larry Martell wrote:
> I need to remove all trailing zeros to the right of the decimal
> point, but leave one zero if it's whole number.
>
> But I can't figure out how to get the 5. to be 5.0.
> I've been messing with the negative lookbehind, but I haven't fou
On 2015-03-13 16:05, Larry Martell wrote:
I need to remove all trailing zeros to the right of the decimal point,
but leave one zero if it's whole number. For example, if I have this:
14S,5.,4.5686274500,3.7272727272727271,3.3947368421052630,5.7307692307692308,5.75471698113207
Larry Martell wrote:
> I need to remove all trailing zeros to the right of the decimal point,
> but leave one zero if it's whole number. For example, if I have this:
>
>
14S,5.,4.5686274500,3.7272727272727271,3.3947368421052630,5.7307692307692308,5.7547169811320753,4.94230769
On Saturday, December 20, 2014 12:01:10 PM UTC+5:30, Rustom Mody wrote:
> I remember seeing here (couple of weeks ago??) a mention of a regex
> debugging/editing tool hidden away in the python source tree.
>
> Does someone remember the name/path?
>
> There are of course dozens of online ones...
massi_...@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 $"
On 28Oct2014 04:02, massi_...@msn.com wrote:
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 $"some
On 2014-10-28 12:28, massi_...@msn.com wrote:
Hi Chris, thanks for the reply. I tried to use look ahead assertions, in
particular I modified the regex this way:
newstring = re.sub(ur"""(?u)(\$\"[\s\w(?<=\\)\"]+\")""", subst, oldstring)
but it does not work. I'm absolutely not a regex guru so I
On Tuesday, October 28, 2014 7:03:00 AM UTC-4, mass...@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 substi
On Tue, Oct 28, 2014 at 4:02 AM, 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 i
(Please quote enough of the previous text to provide context, and
write your replies underneath the quoted text - don't assume that
everyone's read the previous posts. Thanks!)
On Tue, Oct 28, 2014 at 11:28 PM, wrote:
> Hi Chris, thanks for the reply. I tried to use look ahead assertions, in
>
Hi Chris, thanks for the reply. I tried to use look ahead assertions, in
particular I modified the regex this way:
newstring = re.sub(ur"""(?u)(\$\"[\s\w(?<=\\)\"]+\")""", subst, oldstring)
but it does not work. I'm absolutely not a regex guru so I'm surely missing
something. The strings I'm d
On Tue, Oct 28, 2014 at 10:02 PM, wrote:
> 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 :-)
Yeah, that sort of thing is perfectly welcome here. Same with
questions about networking in Python, or file I/
On Thu, 27 Mar 2014 06:41:55 -0700 (PDT), James Smith wrote:
> On Thursday, March 27, 2014 1:32:03 AM UTC-4, Steven D'Aprano wrote:
>
>> - are you mistaken about the content of the file?
>>
>> I can't help you with the first. But the second: try running this:
>>
>> # line2 and pat as defined abov
On Thursday, March 27, 2014 9:41:55 AM UTC-4, James Smith wrote:
> (134, False, '\'
> "SHELF-17:LOG_COLN_IP,SC,03-25,01-18-58,NEND,NA,,,:"Log Collection In
> Progress",NONE:170035-6364-1048,:YEAR=2014,MODE=NONE"\\r\\n\'')
>
>
>
> Is the \r\n on the end of the line screwing it up
On Thursday, March 27, 2014 1:32:03 AM UTC-4, Steven D'Aprano wrote:
> - are you mistaken about the content of the file?
>
> I can't help you with the first. But the second: try running this:
>
> # line2 and pat as defined above
> filename = sys.argv[1]
> with open(filename) as f:
> for line
On Wed, 26 Mar 2014 20:23:29 -0700, James Smith wrote:
> I can't get this to work.
> It runs but there is no output when I try it on a file.
Simplify, simplify, simplify. Either you will find the problem, or you
will find the simplest example that demonstrates the problem.
In this case, the pro
On Thu, Mar 27, 2014 at 3:14 PM, James Smith wrote:
> I tried the re.M in the compile and that didn't help.
Okay. Try printing out the repr of the line at the point where you
have the commented-out write to stdout. That might tell you if there's
some other difference. At that point, you'll know i
On Thursday, March 27, 2014 8:53:29 AM UTC+5:30, James Smith wrote:
> I can't get this to work.
> It runs but there is no output when I try it on a file.
> #!/usr/bin/python
> import os
> import sys
> import re
> from datetime import datetime
> #logDir = '/nfs/projects/equinox/platformTools/RTLG
On Wednesday, March 26, 2014 11:23:29 PM UTC-4, James Smith wrote:
> I can't get this to work.
>
> It runs but there is no output when I try it on a file.
>
>
>
>
>
> #!/usr/bin/python
>
>
>
> import os
>
> import sys
>
> import re
>
> from datetime import datetime
>
>
>
> #logDir =
On Thu, Mar 27, 2014 at 2:23 PM, James Smith wrote:
> re.M
> p = re.compile('^\s*\"SHELF-.*,SC,.*,:\\\"Log Collection In Progress\\\"')
If you're expecting this to be parsed as a multiline regex, it won't
be. Probing re.M doesn't do anything on its own; you have to pass it
as an argument to compi
On 20/01/2014 17:09, Neil Cerutti wrote:
On 2014-01-20, Devin Jeanpierre wrote:
On Mon, Jan 20, 2014 at 8:16 AM, Mark Lawrence
wrote:
On 20/01/2014 16:04, Neil Cerutti wrote:
I use regular expressions regularly, for example, when
editing text with gvim. But when I want to use them in Python
ces that are outside of your sphere of control prevent you from doing
so?
I don't see any way in which someone uncomfortable with the re module
would magically find themselves perfectly at home with the regex
module. The regex module is the re module with some extra features
(and complexit
hat you'd like to use regex but other
> > influences that are outside of your sphere of control prevent you from doing
> > so?
> I don't see any way in which someone uncomfortable with the re module
> would magically find themselves perfectly at home with the regex
> modu
On 2014-01-20, Devin Jeanpierre wrote:
> On Mon, Jan 20, 2014 at 8:16 AM, Mark Lawrence
> wrote:
>> On 20/01/2014 16:04, Neil Cerutti wrote:
>>> I use regular expressions regularly, for example, when
>>> editing text with gvim. But when I want to use them in Python
>>> I have to contend with the
On Mon, Jan 20, 2014 at 8:16 AM, Mark Lawrence wrote:
> On 20/01/2014 16:04, Neil Cerutti wrote:
>> I use regular expressions regularly, for example, when editing
>> text with gvim. But when I want to use them in Python I have to
>> contend with the re module. I've never become comfortable with
>>
On 20/01/2014 16:04, Neil Cerutti wrote:
On 2014-01-20, Roy Smith wrote:
In article
, Ben
Finney wrote:
Be aware that regex is not the solution to all parsing
problems; for many parsing problems it is an attractive but
inappropriate tool. You may need to construct a more specific
parser for y
1 - 100 of 571 matches
Mail list logo