On Aug 18, 12:22 pm, Jussi Piitulainen
wrote:
> Frank Koshti writes:
> > not always placed in HTML, and even in HTML, they may appear in
> > strange places, such as Hello. My specific issue
> > is I need to match, process and replace $foo(x=3), knowing that
> > (x=3) is optional, and the token mig
Steven,
Well done!!!
Regards,
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list
Frank Koshti writes:
> not always placed in HTML, and even in HTML, they may appear in
> strange places, such as Hello. My specific issue
> is I need to match, process and replace $foo(x=3), knowing that
> (x=3) is optional, and the token might appear simply as $foo.
>
> To do this, I decided to
On Aug 18, 11:48 am, Peter Otten <__pete...@web.de> wrote:
> Frank Koshti wrote:
> > I need to match, process and replace $foo(x=3), knowing that (x=3) is
> > optional, and the token might appear simply as $foo.
>
> > To do this, I decided to use:
>
> > re.compile('\$\w*\(?.*?\)').findall(mystring)
2012/8/18 Frank Koshti :
> Hey Steven,
>
> Thank you for the detailed (and well-written) tutorial on this very
> issue. I actually learned a few things! Though, I still have
> unresolved questions.
>
> The reason I don't want to use an XML parser is because the tokens are
> not always placed in HTM
Frank Koshti wrote:
> I need to match, process and replace $foo(x=3), knowing that (x=3) is
> optional, and the token might appear simply as $foo.
>
> To do this, I decided to use:
>
> re.compile('\$\w*\(?.*?\)').findall(mystring)
>
> the issue with this is it doesn't match $foo by itself, and
Hey Steven,
Thank you for the detailed (and well-written) tutorial on this very
issue. I actually learned a few things! Though, I still have
unresolved questions.
The reason I don't want to use an XML parser is because the tokens are
not always placed in HTML, and even in HTML, they may appear in
On Fri, 17 Aug 2012 21:41:07 -0700, Frank Koshti wrote:
> Hi,
>
> I'm new to regular expressions. I want to be able to match for tokens
> with all their properties in the following examples. I would appreciate
> some direction on how to proceed.
Others have already given you excellent advice to
I think the point was missed. I don't want to use an XML parser. The
point is to pick up those tokens, and yes I've done my share of RTFM.
This is what I've come up with:
'\$\w*\(?.*?\)'
Which doesn't work well on the above example, which is partly why I
reached out to the group. Can anyone help
In article
<385e732e-1c02-4dd0-ab12-b92890bbe...@o3g2000yqp.googlegroups.com>,
Frank Koshti wrote:
> I'm new to regular expressions. I want to be able to match for tokens
> with all their properties in the following examples. I would
> appreciate some direction on how to proceed.
>
>
> @foo1
On 18/08/2012 06:42, Chris Angelico wrote:
On Sat, Aug 18, 2012 at 2:41 PM, Frank Koshti wrote:
Hi,
I'm new to regular expressions. I want to be able to match for tokens
with all their properties in the following examples. I would
appreciate some direction on how to proceed.
@foo1
@foo2()
@f
On Sat, Aug 18, 2012 at 2:41 PM, Frank Koshti wrote:
> Hi,
>
> I'm new to regular expressions. I want to be able to match for tokens
> with all their properties in the following examples. I would
> appreciate some direction on how to proceed.
>
>
> @foo1
> @foo2()
> @foo3(anything could go here)
On 29/07/11 19:52, Rustom Mody wrote:
> MRAB wrote:
> > findall returns a list of tuples (what the groups captured) if there
> is more than 1 group,
> > or a list of strings (what the group captured) if there is 1 group,
> or a list of
> > strings (what the regex matched) if there are no groups.
>
MRAB wrote:
> findall returns a list of tuples (what the groups captured) if there is
more than 1 group,
> or a list of strings (what the group captured) if there is 1 group, or a
list of
> strings (what the regex matched) if there are no groups.
Thanks.
It would be good to put this in the manual
On 29/07/2011 16:45, Thomas Jollans wrote:
On 29/07/11 16:53, rusi wrote:
Can someone throw some light on this anomalous behavior?
import re
r = re.search('a(b+)', 'ababbaaab')
r.group(1)
'b'
r.group(0)
'ab'
r.group(2)
Traceback (most recent call last):
File "", line 1, in
IndexErr
On 29/07/11 16:53, rusi wrote:
> Can someone throw some light on this anomalous behavior?
>
import re
r = re.search('a(b+)', 'ababbaaab')
r.group(1)
> 'b'
r.group(0)
> 'ab'
r.group(2)
> Traceback (most recent call last):
> File "", line 1, in
> IndexError: no such gr
Many thanks to all who replied! And, yes, I will *definitely* use raw
strings from now on. :)
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
Ethan Furman wrote:
Greetings!
My closest to successfull attempt:
Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit
(Intel)]
Type "copyright", "credits" or "license" for more information.
IPython 0.9.1 -- An enhanced Interactive Python.
In [161]: re.findall('\d+','this i
On Thu, 02 Jul 2009 09:38:56 -0700, Ethan Furman wrote:
> Greetings!
>
> My closest to successfull attempt:
>
> Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)]
> Type "copyright", "credits" or "license" for more information.
>
> IPython 0.9.1 -- An enhanced Interact
On 2009-07-02 18:38, Ethan Furman wrote:
Greetings!
My closest to successfull attempt:
Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit
(Intel)]
Type "copyright", "credits" or "license" for more information.
IPython 0.9.1 -- An enhanced Interactive Python.
In [161]: re.find
Ethan Furman wrote:
Greetings!
My closest to successfull attempt:
Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)]
Type "copyright", "credits" or "license" for more information.
IPython 0.9.1 -- An enhanced Interactive Python.
In [161]: re.findall('\d+','this is
On Tue, 05 Aug 2008 15:55:46 +0100, Fred Mangusta wrote:
> Chris wrote:
>
>> Doesn't work for his use case as he wants to keep periods marking the
>> end of a sentence.
Doesn't it? The period has to be surrounded by digits in the
example solution, so wouldn't periods followed by a space
(end of
On Aug 5, 11:39 am, Fred Mangusta <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I would like to delete all the instances of a '.' into a number.
>
> In other words I'd like to replace all the instances of a '.' character
> with something (say nothing at all) when the '.' is representing a
> decimal separato
Chris wrote:
Doesn't work for his use case as he wants to keep periods marking the
end of a sentence.
Exactly. Thanks to all of you anyway, now I have a better understanding
on how to go on :)
F.
--
http://mail.python.org/mailman/listinfo/python-list
On Aug 5, 2:23 pm, Jeff <[EMAIL PROTECTED]> wrote:
> On Aug 5, 7:10 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Tue, 05 Aug 2008 11:39:36 +0100, Fred Mangusta wrote:
> > > In other words I'd like to replace all the instances of a '.' character
> > > with something (say noth
=)
Indeed. But it will replace all dots including ordinary strings instead of
numbers only.
On Tue, Aug 5, 2008 at 3:23 PM, Jeff <[EMAIL PROTECTED]> wrote:
> On Aug 5, 7:10 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> > On Tue, 05 Aug 2008 11:39:36 +0100, Fred Mangusta wrote:
> > > I
On Aug 5, 7:10 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> On Tue, 05 Aug 2008 11:39:36 +0100, Fred Mangusta wrote:
> > In other words I'd like to replace all the instances of a '.' character
> > with something (say nothing at all) when the '.' is representing a
> > decimal separator.
No, there is a bad way - because of the example doesn't solve arbitrary
amount of ... blocks.
But the python regexp engine supports for lookahead (?=pattern) and
lookbehind (?<=pattern).
In those cases patterns are not included into the replaced sequence of
characters:
>>> re.sub('(?<=\d)\.(?=\d)',
On Tue, 05 Aug 2008 11:39:36 +0100, Fred Mangusta wrote:
> In other words I'd like to replace all the instances of a '.' character
> with something (say nothing at all) when the '.' is representing a
> decimal separator. E.g.
>
> 500.675 > 500675
>
> but also
>
> 1.000.456.344 >
On Feb 13, 6:53 am, mathieu <[EMAIL PROTECTED]> wrote:
> I do not understand what is wrong with the following regex expression.
> I clearly mark that the separator in between group 3 and group 4
> should contain at least 2 white space, but group 3 is actually reading
> 3 +4
>
> Thanks
> -Mathieu
>
On Feb 13, 1:53 pm, mathieu <[EMAIL PROTECTED]> wrote:
> I do not understand what is wrong with the following regex expression.
> I clearly mark that the separator in between group 3 and group 4
> should contain at least 2 white space, but group 3 is actually reading
> 3 +4
>
> Thanks
> -Mathieu
>
mathieu, stop writing complex REs like obfuscated toys, use the
re.VERBOSE flag and split that RE into several commented and
*indented* lines (indented just like Python code), the indentation
level has to be used to denote nesting. With that you may be able to
solve the problem by yourself. If not,
Hey Mathieu
Due to word wrap I'm not sure what you want to do. What result do you
expect? I get:
>>> print m.groups()
('0021', 'xx0A', 'Siemens: Thorax/Multix FD Lab Settings Auto Window
Width ', ' ', 'SL', '1')
But only when I insert a space in the 3rd char group (I'm not sure if
your origin
On 15:25 Thu 04 Oct , Robert Dailey wrote:
> I am not a regex expert, I simply assumed regex was standardized to follow
> specific guidelines.
There are as many different regex flavours as there are Linux distros.
Each follows the basic rules but implements them slightly differently
and adds t
I am not a regex expert, I simply assumed regex was standardized to follow
specific guidelines. I also made the assumption that this was a good place
to pose the question since regular expressions are a feature of Python. The
question concerned regular expressions in general, not really the
applica
[sigh...replying to my own post]
> However, things to try:
>
> - sometimes the grouping parens need to be escaped with "\"
>
> - sometimes "\w" isn't a valid character class, so use the
> long-hand variant of something like "[a-zA-Z0-9_]]
>
> - sometimes the "+" is escaped with a "\"
>
> - if
>>> try @param\[(in|out)\] \w+
>>>
>> This didn't work either :(
>>
>> The tool using this regular expression (Comment Reflower for VS2005) May be
>> broken...
>
> How about @param\[[i|o][n|u]t*\]\w+ ?
...if you want to accept patterns like
@param[iutt]xxx
...
The regexp at the top
On 10/4/07, Robert Dailey <[EMAIL PROTECTED]> wrote:
> On 10/4/07, Adam Lanier <[EMAIL PROTECTED]> wrote:
> >
> > try @param\[(in|out)\] \w+
> >
>
> This didn't work either :(
>
> The tool using this regular expression (Comment Reflower for VS2005) May be
> broken...
>
> --
> http://mail.python.org
> As far as the dialect, I can't be sure. I am unable to find documentation
> for Comment Reflower and thus cannot figure out what type of regex it is
> using. What exactly do you mean by your question, "are you using raw
> strings?". Thanks for your response and I apologize for the lack of detail.
On 10/4/07, J. Clifford Dyer <[EMAIL PROTECTED]> wrote:
>
> You *are* talking about python regular expressions, right? There are a
> number of different dialects. Also, there could be issues with the quoting
> method (are you using raw strings?)
>
> The more specific you can get, the more we can
-0500, Robert Dailey wrote regarding Re:
RegEx question:
>
>On 10/4/07, Adam Lanier <[EMAIL PROTECTED]> wrote:
>
> try @param\[(in|out)\] \w+
>
>This didn't work either :(
>The tool using this regular expression (Comment Reflower for VS2005)
>
On 10/4/07, Adam Lanier <[EMAIL PROTECTED]> wrote:
>
>
> try @param\[(in|out)\] \w+
>
This didn't work either :(
The tool using this regular expression (Comment Reflower for VS2005) May be
broken...
--
http://mail.python.org/mailman/listinfo/python-list
On Thu, 2007-10-04 at 10:58 -0500, Robert Dailey wrote:
> It should also match:
>
> @param[out] state Some description of this variable
>
>
> On 10/4/07, Robert Dailey <[EMAIL PROTECTED]> wrote:
> Hi,
>
> The following regex (Not including the end quotes):
>
>
It should also match:
@param[out] state Some description of this variable
On 10/4/07, Robert Dailey <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> The following regex (Not including the end quotes):
>
> "@param\[in|out\] \w+ "
>
> Should match any of the following:
>
> @param[in] variable
> @param[out]
On Apr 27, 8:26 am, Michael Hoffman <[EMAIL PROTECTED]> wrote:
> proctorwrote:
> > On Apr 27, 1:33 am, Paul McGuire <[EMAIL PROTECTED]> wrote:
> >> On Apr 27, 1:33 am,proctor<[EMAIL PROTECTED]> wrote:
> >>> rx_test = re.compile('/x([^x])*x/')
> >>> s = '/xabcx/'
> >>> if rx_test.findall(s):
> >>>
On Apr 27, 8:50 am, Paul McGuire <[EMAIL PROTECTED]> wrote:
> On Apr 27, 9:10 am, proctor <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Apr 27, 1:33 am, Paul McGuire <[EMAIL PROTECTED]> wrote:
>
> > > On Apr 27, 1:33 am, proctor <[EMAIL PROTECTED]> wrote:
>
> > > > hello,
>
> > > > i have a regex: rx_te
proctor <[EMAIL PROTECTED]> wrote:
>> >>> re.findall('(.)*', 'abc')
>> ['c', '']
> thank you this is interesting. in the second example, where does the
> 'nothingness' match, at the end? why does the regex 'run again' when
> it has already matched everything? and if it reports an empty match
>
On Apr 27, 8:37 am, Duncan Booth <[EMAIL PROTECTED]> wrote:
> proctor <[EMAIL PROTECTED]> wrote:
> > so my question remains, why doesn't the star quantifier seem to grab
> > all the data. isn't findall() intended to return all matches? i
> > would expect either 'abc' or 'a', 'b', 'c' or at least
On Apr 27, 8:26 am, Michael Hoffman <[EMAIL PROTECTED]> wrote:
> proctor wrote:
> > On Apr 27, 1:33 am, Paul McGuire <[EMAIL PROTECTED]> wrote:
> >> On Apr 27, 1:33 am, proctor <[EMAIL PROTECTED]> wrote:
> >>> rx_test = re.compile('/x([^x])*x/')
> >>> s = '/xabcx/'
> >>> if rx_test.findall(s):
> >>
On Apr 27, 9:10 am, proctor <[EMAIL PROTECTED]> wrote:
> On Apr 27, 1:33 am, Paul McGuire <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > On Apr 27, 1:33 am, proctor <[EMAIL PROTECTED]> wrote:
>
> > > hello,
>
> > > i have a regex: rx_test = re.compile('/x([^x])*x/')
>
> > > which is part of this test pr
proctor <[EMAIL PROTECTED]> wrote:
> so my question remains, why doesn't the star quantifier seem to grab
> all the data. isn't findall() intended to return all matches? i
> would expect either 'abc' or 'a', 'b', 'c' or at least just
> 'a' (because that would be the first match). why does it gi
proctor wrote:
> On Apr 27, 1:33 am, Paul McGuire <[EMAIL PROTECTED]> wrote:
>> On Apr 27, 1:33 am, proctor <[EMAIL PROTECTED]> wrote:
>>> rx_test = re.compile('/x([^x])*x/')
>>> s = '/xabcx/'
>>> if rx_test.findall(s):
>>> print rx_test.findall(s)
>>>
>>> i expect the output
On Apr 27, 1:33 am, Paul McGuire <[EMAIL PROTECTED]> wrote:
> On Apr 27, 1:33 am, proctor <[EMAIL PROTECTED]> wrote:
>
>
>
> > hello,
>
> > i have a regex: rx_test = re.compile('/x([^x])*x/')
>
> > which is part of this test program:
>
> >
>
> > import re
>
> > rx_test = re.compile('/
On Apr 27, 1:33 am, proctor <[EMAIL PROTECTED]> wrote:
> hello,
>
> i have a regex: rx_test = re.compile('/x([^x])*x/')
>
> which is part of this test program:
>
>
>
> import re
>
> rx_test = re.compile('/x([^x])*x/')
>
> s = '/xabcx/'
>
> if rx_test.findall(s):
> print rx_tes
proctor wrote:
> i have a regex: rx_test = re.compile('/x([^x])*x/')
You probably want...
rx_test = re.compile('/x([^x]*)x/')
- Josiah
--
http://mail.python.org/mailman/listinfo/python-list
Gabriel Genellina wrote:
> At Tuesday 16/1/2007 16:36, Bill Mill wrote:
>
> > > py> import re
> > > py> rgx = re.compile('1?')
> > > py> rgx.search('a1').groups()
> > > (None,)
> > > py> rgx = re.compile('(1)+')
> > > py> rgx.search('a1').groups()
> >
> >But shouldn't the ? be greedy, and thus pre
At Tuesday 16/1/2007 16:36, Bill Mill wrote:
> py> import re
> py> rgx = re.compile('1?')
> py> rgx.search('a1').groups()
> (None,)
> py> rgx = re.compile('(1)+')
> py> rgx.search('a1').groups()
But shouldn't the ? be greedy, and thus prefer the one match to the
zero? This is my sticking point
James Stroud wrote:
> Bill Mill wrote:
> > Hello all,
> >
> > I've got a test script:
> >
> > start python code =
> >
> > tests2 = ["item1: alpha; item2: beta. item3 - gamma--",
> > "item1: alpha; item3 - gamma--"]
> >
> > def test_re(regex):
> >r = re.compile(regex, re.MULTILINE)
> >
Bill Mill wrote:
> Hello all,
>
> I've got a test script:
>
> start python code =
>
> tests2 = ["item1: alpha; item2: beta. item3 - gamma--",
> "item1: alpha; item3 - gamma--"]
>
> def test_re(regex):
>r = re.compile(regex, re.MULTILINE)
>for test in tests2:
>res = r.se
> yes, i suppose you are right. i can't think of a reason i would NEED a
> raw string in this situation.
It looks from your code that you are trying to remove all occurances of
one string from the other. a simple regex way would be to use re.sub()
>>> import re
>>> a = "abc"
>>> b = "debcabbde"
Paul McGuire wrote:
> "proctor" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> >
> >
> > it does work now...however, one more question: when i type:
> >
> > rx_a = re.compile(r'a|b|c')
> > it works correctly!
> >
>
> Do you see the difference between:
>
> rx_a = re.compile(r'a|b|
Mark Peters wrote:
> > is there any way i would be successful then, in using raw string inside
> > my makeRE() function?
>
> Why do you think you even need a raw string?
>
> Just build and return the string 'a|b|c' (NOTE: DON'T add the quotes to
> the string)
yes, i suppose you are right. i can'
"proctor" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
>
> it does work now...however, one more question: when i type:
>
> rx_a = re.compile(r'a|b|c')
> it works correctly!
>
Do you see the difference between:
rx_a = re.compile(r'a|b|c')
and
rx_a = re.compile("r'a|b|c'")
Th
> is there any way i would be successful then, in using raw string inside
> my makeRE() function?
Why do you think you even need a raw string?
Just build and return the string 'a|b|c' (NOTE: DON'T add the quotes to
the string)
--
http://mail.python.org/mailman/listinfo/python-list
Steven D'Aprano wrote:
> On Sun, 07 Jan 2007 23:57:00 -0800, proctor wrote:
>
> > it does work now...however, one more question: when i type:
> >
> > rx_a = re.compile(r'a|b|c')
> > it works correctly!
> >
> > shouldn't:
> > rx_a = re.compile(makeRE(test))
> > give the same result since makeRE(te
On Sun, 07 Jan 2007 23:57:00 -0800, proctor wrote:
> it does work now...however, one more question: when i type:
>
> rx_a = re.compile(r'a|b|c')
> it works correctly!
>
> shouldn't:
> rx_a = re.compile(makeRE(test))
> give the same result since makeRE(test)) returns the string "r'a|b|c'"
Those
Paul McGuire wrote:
> "proctor" <[EMAIL PROTECTED]> wrote in message
> news:<[EMAIL PROTECTED]>...
> > hello,
> >
> > i hope this is the correct place...
> >
> > i have an issue with some regex code i wonder if you have any insight:
> >
> >
>
> There's nothing actually *wrong* wth
"proctor" <[EMAIL PROTECTED]> wrote in message
news:<[EMAIL PROTECTED]>...
> hello,
>
> i hope this is the correct place...
>
> i have an issue with some regex code i wonder if you have any insight:
>
>
There's nothing actually *wrong* wth your regex. The problem is your
misun
On Fri, 04 Aug 2006 14:55:34 -0700
John Machin <[EMAIL PROTECTED]> wrote:
#> > def test(data):
#> > format, index = 'abcd', 0
#> > for c in data:
#> > i = format.index(c)
#> > if i > index+1:
#> > return False
#> > index = i
#> > return index==format
Slawomir Nowaczyk wrote:
> On Thu, 03 Aug 2006 22:10:55 +0100
> Gabriel Murray <[EMAIL PROTECTED]> wrote:
>
> #> Hello, I'm looking for a regular expression
>
> Some people, when confronted with a problem, think "I know, I'll
> use regular expressions." Now they have two problems.
>
On Thu, 03 Aug 2006 22:10:55 +0100
Gabriel Murray <[EMAIL PROTECTED]> wrote:
#> Hello, I'm looking for a regular expression
Some people, when confronted with a problem, think "I know, I'll
use regular expressions." Now they have two problems.
-- Jamie Z
taleinat wrote:
> Gabriel Murray gmail.com> writes:
>
> >
> > Hello, I'm looking for a regular expression which will match strings as
> follows: if there are symbols a, b, c and d, then any pattern is valid if it
> begins with a and ends with d and proceeds in order through the symbols.
> However
Gabriel Murray gmail.com> writes:
>
> Hello, I'm looking for a regular expression which will match strings as
follows: if there are symbols a, b, c and d, then any pattern is valid if it
begins with a and ends with d and proceeds in order through the symbols.
However, at any point the pattern ma
This might be more flexible:
pat = re.compile(r"^(a*(?=b)b*(?=[ac])c*(?=[abd])d*)+$")
tests = [('aabbbaabbcccbbbcccddd', True),
('aabcabcd', True),
('abcd', True),
('aabbccaabbccabcabababbb', True),
('aabbccaabbccabcabababbbabcd', True),
> That's great! Thanks for the quick response. Yeah, abcdcd should be
> possible too.
The below passes that test now as well as a couple others I
tossed at it.
I changed it from a one-line regexp to a VERBOSE regexp to make
it easier to read and see what's going on. You may be able to
see th
Gabriel Murray wrote:
> Hello, I'm looking for a regular expression which will match strings as
> follows: if there are symbols a, b, c and d, then any pattern is valid if it
> begins with a and ends with d and proceeds in order through the symbols.
> However, at any point the pattern may reset to
Here's a pyparsing version of this, that may be easier to maintain long
term (although if you have your heart set on learning regexp's, they
will certainly do the job). Note that in pyparsing, you don't have to
spell out where the whitespace goes - pyparsing's default logic assumes
that whitespace
"Felix Schwarz" <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I'm experiencing problems with a regular expression and I can't figure
> out which words I use when googling. I read the python documentation for
> the re module multiple times now but still no idea what I'm doing wrong.
>
> What I want to d
Felix Schwarz wrote:
> Hi all,
>
> I'm experiencing problems with a regular expression and I can't figure
> out which words I use when googling. I read the python documentation for
> the re module multiple times now but still no idea what I'm doing wrong.
>
> What I want to do:
> - Extract all
79 matches
Mail list logo