On Oct 2, 11:14 pm, greg wrote:
> Brian D wrote:
> > This isn't merely a question of knowing when to use the right
> > tool. It's a question about how to become a better developer using
> > regular expressions.
>
> It could be said that if you want to learn how to use a
> hammer, it's better to pr
like to turn that re.compile pattern into a MULTILINE
expression, combining the re.M and re.X flags?
Documentation says that one should be able to use the bitwise OR
operator (e.g., re.M | re.X), but I sure couldn't get it to work.
Sometimes a hammer actually is the right tool if you hit th
I'm kind of new to regular expressions, and I've spent hours trying to
finesse a regular expression to build a substitution.
What I'd like to do is extract data elements from HTML and structure
them so that they can more readily be imported into a database.
No -- sorry -- I don't want to use Beau
On Jun 10, 10:13 am, Peter Otten <__pete...@web.de> wrote:
> 504cr...@gmail.com wrote:
> > I wonder if you (or anyone else) might attempt a different explanation
> > for the use of the special sequence '\1' in the RegEx syntax.
>
> > The Python documentation
On Jun 11, 2:01 am, Lie Ryan wrote:
> 504cr...@gmail.com wrote:
> > I've encountered a problem with my RegEx learning curve -- how to
> > escape hash characters # in strings being matched, e.g.:
>
> >>>> string = re.escape('123#abc456')
> >
I've encountered a problem with my RegEx learning curve -- how to
escape hash characters # in strings being matched, e.g.:
>>> string = re.escape('123#abc456')
>>> match = re.match('\d+', string)
>>> print match
<_sre.SRE_Match object at 0x00A6A800>
>>> print match.group()
123
The correct resul
On Jun 10, 5:17 am, Paul McGuire wrote:
> On Jun 9, 11:13 pm, "504cr...@gmail.com" <504cr...@gmail.com> wrote:
>
> > By what method would a string be inserted at each instance of a RegEx
> > match?
>
> Some might say that using a parsing library for this pr
On Jun 9, 11:35 pm, "504cr...@gmail.com" <504cr...@gmail.com> wrote:
> On Jun 9, 11:19 pm, Roy Smith wrote:
>
>
>
> > In article
> > ,
>
> > "504cr...@gmail.com" <504cr...@gmail.com> wrote:
> > > By what method would
On Jun 9, 11:19 pm, Roy Smith wrote:
> In article
> ,
>
> "504cr...@gmail.com" <504cr...@gmail.com> wrote:
> > By what method would a string be inserted at each instance of a RegEx
> > match?
>
> > For example:
>
> > string = '123 a
By what method would a string be inserted at each instance of a RegEx
match?
For example:
string = '123 abc 456 def 789 ghi'
newstring = ' INSERT 123 abc INSERT 456 def INSERT 789 ghi'
Here's the code I started with:
>>> rePatt = re.compile('\d+\s')
>>> iterator = rePatt.finditer(string)
>>> co
10 matches
Mail list logo