Share your knowledge at the LQ Wiki.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 12-19-2003, 12:22 PM   #1
Registered: Oct 2003
Distribution: Debian
Posts: 39

Rep: Reputation: 15
regular expressions and back references within [] lists

It seems like a simple problem at first.

Let's start with an example:

using the data set
I would like to be able to match the words war and wet while excluding wee and woo.

I can match wee and woo with this expression:
Is there a way to use "back references" within [] lists?

The expression:
does not produce the same results as the previous expression because instead of resolving the '\1' to an 'e' or 'o', it searches for the '\\' and '1' characters.

The reason this is a problem is that I thought that I would be able to write an expression like this:
So is there any way to resolve a back reference within [] lists?

I've been trying to think back to my CS classes to remember if it's even possible for REs to do this sort of thing.
Old 12-19-2003, 01:53 PM   #2
Registered: Oct 2002
Location: Curitiba - Brazil
Distribution: Conectiva
Posts: 334

Rep: Reputation: 30
The usual reference is [^], but in this case will not work, so is easier to use an work around, like in egrep use the option -v to reverse the result of this expression...


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Regular Expressions markjuggles Programming 2 05-05-2005 11:39 AM
Regular Expressions overbored Linux - Software 3 06-24-2004 02:34 PM
help with REGULAR EXPRESSIONS ner Linux - General 23 10-31-2003 11:09 PM
Regular expressions aromes Linux - General 1 10-15-2003 12:29 PM
regular expressions? alaios Linux - General 2 06-11-2003 03:51 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:28 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration