[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Quickie - Regexp for a string not at the beginning of the line

From: Ed Morton
Subject: Re: Quickie - Regexp for a string not at the beginning of the line
Date: Thu, 25 Oct 2012 21:00:32 -0500
User-agent: Mozilla/5.0 (Windows NT 5.1; rv:16.0) Gecko/20121010 Thunderbird/16.0.1

On 10/25/2012 8:08 PM, Rivka Miller wrote:
On Oct 25, 2:27 pm, Danny <> wrote:
Why you just don't give us the string/input, say a line or two, and what you 
want off of it, so we can tell better what to suggest

no one has really helped yet.

Because there is no solution - there IS no _RE_ that will match a string not at the beginning of a line.

Now if you want to know how to extract a string that matches an RE in awk, that'd be (just one way):

   awk 'match($0,/.[$]hello[$]/) { print substr($0,RSTART+1,RLENGTH-1) }'

and other tools would have their ways of producing the same output, but that's not the question you're asking.


I want to search and modify.

I dont wanna be tied to a specific language etc so I just want a
regexp and as many versions as possible. Maybe I should try in emacs
and so I am now posting to emacs groups also, although javascript has
rich set of regexp facilities.


$hello$ should not be selected but
not hello but all of the $hello$ and $hello$ ... $hello$ each one

original post

Hello Programmers,

I am looking for a regexp for a string not at the beginning of the

For example, I want to find $hello$ that does not occur at the
beginning of the string, ie all $hello$ that exclude ^$hello$.

In addition, if you have a more difficult problem along the same
lines, I would appreciate it. For a single character, eg < not at the
beginning of the line, it is easier, ie


but I cant use the same method for more than one character string as
permutation is present and probably for more than one occurrence,
greedy or non-greedy version of [^<]+ would pick first or last but not
the middle ones, unless I break the line as I go and use the non-
greedy version of +. I do have the non-greedy version available, but
what if I didnt?

If you cannot solve the problem completely, just give me a quick
solution with the first non beginning of the line and I will go from
there as I need it in a hurry.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]