473,405 Members | 2,282 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,405 software developers and data experts.

Negative regular expressions (searching for "i" not inside command)

I have a file in which I am searching for the letter "i" (actually
a bit more general than that, arbitrary regular expressions could
occur) as long as it does not occur inside an expression that matches
\\.+?\b (something started by a backslash and including the word that
follows).

More concrete example, I have the string "\sin(i)" and I want to match
the argument, but not the i in \sin.

Can this be achieved by combining the regular expressions? I do not
know the right terminology involved, therefore my searching on the
Internet has not led to any results.

I can achieve something like this by searching for all i and then
throwing away those i that are inside such expressions. I am now just
wondering if these two steps can be combined into one.

Best,
Bart
--
http://www.bartk.nl/
Aug 28 '08 #1
2 1495
On Thu, Aug 28, 2008 at 5:04 PM, Bart Kastermans
<ka******@math.wisc.edu${hostname}wrote:
I have a file in which I am searching for the letter "i" (actually
a bit more general than that, arbitrary regular expressions could
occur) as long as it does not occur inside an expression that matches
\\.+?\b (something started by a backslash and including the word that
follows).

More concrete example, I have the string "\sin(i)" and I want to match
the argument, but not the i in \sin.

Can this be achieved by combining the regular expressions? I do not
know the right terminology involved, therefore my searching on the
Internet has not led to any results.
Try searching again with the "lookahead" term, or "negative lookahead".
>
I can achieve something like this by searching for all i and then
throwing away those i that are inside such expressions. I am now just
wondering if these two steps can be combined into one.

Best,
Bart
--
http://www.bartk.nl/
--
http://mail.python.org/mailman/listinfo/python-list


--
-- Guilherme H. Polo Goncalves
Aug 28 '08 #2
On Aug 28, 4:04*pm, "Guilherme Polo" <ggp...@gmail.comwrote:
On Thu, Aug 28, 2008 at 5:04 PM, Bart Kastermans

<kaste...@math.wisc.edu${hostname}wrote:
I have a file in which I am searching for the letter "i" (actually
a bit more general than that, arbitrary regular expressions could
occur) as long as it does not occur inside an expression that matches
\\.+?\b (something started by a backslash and including the word that
follows).
More concrete example, I have the string "\sin(i)" and I want to match
the argument, but not the i in \sin.
Can this be achieved by combining the regular expressions? *I do not
know the right terminology involved, therefore my searching on the
Internet has not led to any results.

Try searching again with the "lookahead" term, or "negative lookahead".
I can achieve something like this by searching for all i and then
throwing away those i that are inside such expressions. *I am now just
wondering if these two steps can be combined into one.
Best,
Bart
--
http://www.bartk.nl/
--
http://mail.python.org/mailman/listinfo/python-list

--
-- Guilherme H. Polo Goncalves
No dice: "This is called a positive lookbehind assertion. ...The
contained pattern must only match strings of some fixed length."
'finditer' could make the 'combined into one' option more attractive
though.
Aug 28 '08 #3

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

Similar topics

6
by: Chris Lasher | last post by:
Hello, I would like to create a set of very similar regular expression. In my initial thought, I'd hoped to create a regular expression with a variable inside of it that I could simply pass a...
1
by: mail | last post by:
Hello, I am trying to use regular expressions to scan a subdirectory structure and run sfv and parity file checks on the directory. However, I am having an issue with my current code using...
11
by: Martin Robins | last post by:
I am trying to parse a string that is similar in form to an OLEDB connection string using regular expressions; in principle it is working, but certain character combinations in the string being...
2
by: John Smith | last post by:
My understanding is that to search for "big" OR "small" in a string, one uses the following expression: r = New Regex("big|small", _ RegexOptions.IgnoreCase Or RegexOptions.Compiled) What is...
3
by: rdi | last post by:
I get the idea of how to create the search patterns. But what I'm having trouble with is how to actually implement regular expressions. I can't seem to find any code that actually USES them. In...
0
by: baskarpr | last post by:
I am doing a utility for java API search in Visual Basic 6.0. When some class name/method name is given as search key, details are shown like package name, class name etc. (I expect the output is to...
3
by: Aaron | last post by:
I'm trying to parse a table on a webpage to pull down some data I need. The page is based off of information entered into a form. when you submit the data from the form it displays a...
0
by: paruljuneja | last post by:
I have a form in which using web browser i have loaded gmail.i have stored username and password in INIfile.now what i want is that when the page gets open username and password automatically get...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.