Re: Problem with repeating characters in regex
- From: mritty@xxxxxxxxx (Paul Lalli)
- Date: Thu, 27 Sep 2007 06:05:11 -0700
On Sep 27, 8:58 am, redt...@xxxxxxxxxxxxxx (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;
This says to search for an exclamation mark, followed by the beginning
of the string (which makes no sense, of course), followed by another
exclamation mark, followed by a capital letter, a lowercase letter,
and then one or more of anything. And replace all of that with
everything except the first exclamation.
it either doesnt capture any ! or takes out the first ! when there is a double
No it doesn't. There is no way this pattern match ever succeeds.
It's not possible to find some character and *then* the beginning of
the string.
Provide sample input and output of what it is you're trying to do.
Your english description of the problem is confusing at best.
Paul Lalli
.
- References:
- Problem with repeating characters in regex
- From: Mike Martin
- Problem with repeating characters in regex
- Prev by Date: Re: $File::Find and no_chdir
- Next by Date: Re: Problem with repeating characters in regex
- Previous by thread: Problem with repeating characters in regex
- Next by thread: Re: Problem with repeating characters in regex
- Index(es):