473,287 Members | 1,560 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

regular expression syntax the same in Python, Perl and grep?

How similar is Python's re module (regular expressions) compared
to Perl's and grep's regular expression syntaxes?

I really hope regular expression syntax is sufficiently standardized
that
we don't have to learn new dialects everytime we move from one
language or shell command to another.

chris

Nov 7 '07 #1
3 2770
On Nov 7, 2007 12:11 PM, se******@spawar.navy.mil
<se******@spawar.navy.milwrote:
How similar is Python's re module (regular expressions) compared
to Perl's and grep's regular expression syntaxes?
Somewhat.
I really hope regular expression syntax is sufficiently standardized
that
we don't have to learn new dialects everytime we move from one
language or shell command to another.
It isn't, at least for non-trivial use of regexps.
Nov 7 '07 #2
2007/11/7, Chris Mellon <ar*****@gmail.com>:
On Nov 7, 2007 12:11 PM, se******@spawar.navy.mil
<se******@spawar.navy.milwrote:
How similar is Python's re module (regular expressions) compared
to Perl's and grep's regular expression syntaxes?

Somewhat.
I really hope regular expression syntax is sufficiently standardized
that
we don't have to learn new dialects everytime we move from one
language or shell command to another.
I forgot where I read that so can't back it up but:

"Unices are just a collection of different dialects of regex"

I think the same is true for about every implementation of regex you
can find. In theory it _should_ be same.

Then again, so should SQL but I bet that it's actually quite hard to
find a single statement that you can literally execute it on all DB
servers (major ones).
--
http://noneisyours.marcher.name
http://feeds.feedburner.com/NoneIsYours
Nov 7 '07 #3
On Nov 7, 12:11 pm, "seber...@spawar.navy.mil"
<seber...@spawar.navy.milwrote:
How similar is Python's re module (regular expressions) compared
to Perl's and grep's regular expression syntaxes?
http://en.wikipedia.org/wiki/Compari...ession_engines

rd
Nov 8 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

23
by: Paul Rubin | last post by:
OK, I want to scan a file for lines matching a certain regexp. I'd like to use an assignment expression, like for line in file: if (g := re.match(pat, line)): croggle(g.group(1)) Since...
6
by: Tony C | last post by:
I'm writing a python program which uses regular expressions, but I'm totally new to regexps. I've got Kuchling's "Regexp HOWTO", "Mastering Regular Expresions" by Oreilly, and have access to...
4
by: pekka niiranen | last post by:
Hi there, I have perl script that uses dynamically constructed regular in this way: ------perl code starts ---- $result ""; $key = AAA\?01; $key = quotemeta $key; $line = " ...
1
by: Kenneth McDonald | last post by:
I'm working on the 0.8 release of my 'rex' module, and would appreciate feedback, suggestions, and criticism as I work towards finalizing the API and feature sets. rex is a module intended to make...
0
by: Xah Lee | last post by:
# -*- coding: utf-8 -*- # Python # David Eppstein of the Geometry Junkyard fame gave this elegant # version for returing all possible pairs from a range of n numbers. def combo2(n): return...
19
by: Davy | last post by:
Hi all, I am a C/C++/Perl user and want to switch to Python (I found Python is more similar to C). Does Python support robust regular expression like Perl? And Python and Perl's File...
1
by: Wehrdamned | last post by:
Hi, As I understand it, python uses a pcre engine to work with regular expression. My question is, then, why expressions like : Traceback (most recent call last): File "<stdin>", line 1, in...
2
by: ravir | last post by:
Hi, I am new to this group. I am working in Perl and shellscripts. I have a clarification regarding perl grep and pattern matching. I am writing a perl script to automate the process of code...
47
by: Henning_Thornblad | last post by:
What can be the cause of the large difference between re.search and grep? This script takes about 5 min to run on my computer: #!/usr/bin/env python import re row="" for a in range(156000):...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.