Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 724
  • Last Modified:

Regular Expression Between Exclude Needs Group Name?

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
pointeman
Asked:
pointeman
  • 2
  • 2
1 Solution
 
käµfm³d 👽Commented:
Try

\^(.*?)\^
0
 
obrienslalomCommented:
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
 
obrienslalomCommented:
Sorry kaufmed...ignore my post
0
 
pointemanAuthor Commented:
This: \^(.*?)\^
Returns this: ^12345678^
I also need to exclude both ^ from the result...
0
 
käµfm³d 👽Commented:
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.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now