Solved

Regular Expression Between Exclude Needs Group Name?

Posted on 2009-05-05
5
674 Views
Last Modified: 2012-05-06
I thought I used this expression (below) with success, but Expresso Regex Builder keeps returning this error:

Error: Invalid Group Name. Group names must begin with a word character

I'm trying to extract everything between ^ and ^ but exclude both ^

(?<\^).*(?=\^)
0
Comment
Question by:pointeman
  • 2
  • 2
5 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 24308916
Try

\^(.*?)\^
0
 
LVL 6

Expert Comment

by:obrienslalom
ID: 24308921
The syntax (?<groupname>pattern) can be used to name a capture group.  The assertions are probably overkill for something like this anyway.  You can get your data by utilizing your capture groups.  Note: the ^ character is an anchor, so they are escaped in the expression.

\^(.*?)\^

Open in new window

0
 
LVL 6

Expert Comment

by:obrienslalom
ID: 24308936
Sorry kaufmed...ignore my post
0
 

Author Comment

by:pointeman
ID: 24309203
This: \^(.*?)\^
Returns this: ^12345678^
I also need to exclude both ^ from the result...
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 250 total points
ID: 24309301
Check the second group:
Match match = Regex.Match("^12345^", "\^(.*?)\^");
 
string result = match.Groups[1].Value;

Open in new window

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question