Re: Problem with repeating characters in regex
- From: rob.dixon@xxxxxxx (Rob Dixon)
- Date: Thu, 27 Sep 2007 14:14:31 +0100
Mike Martin wrote:
Hi I am trying to capture only the first occurence of a charcter
followed by any word ie: in this sample text
!this is a first level heading
!!this is a 2nd level heading
I only want to find the first item and not the second
current code
$line=~s/\!(^\![A-Z][a-z].+)/$1/gc;
it either doesnt capture any ! or takes out the first ! when there is a double
any ideas
Hi Mike. I'm confused as to what you're trying to do, as your regex
doesn't make sense and is a subtitution rather than a pattern match. My
best guess is that you want to elevate all second-level headings to first-
level ones? Maybe something like
$line =~ s/^!(![a-z].+)/$1/gi;
does what you need.
HTH,
Rob
.
- Follow-Ups:
- Re: Problem with repeating characters in regex
- From: John W. Krahn
- Re: Problem with repeating characters in regex
- References:
- Problem with repeating characters in regex
- From: Mike Martin
- Problem with repeating characters in regex
- Prev by Date: Re: Problem with repeating characters in regex
- Next by Date: Re: encoding problem?
- Previous by thread: Re: Problem with repeating characters in regex
- Next by thread: Re: Problem with repeating characters in regex
- Index(es):