Quickie - Regexp for a string not at the beginning of the line
asen.bozhilov at gmail.com
Fri Oct 26 12:46:55 CEST 2012
Rivka Miller wrote:
> 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$.
The begging of the string is zero width character. So you could use
negative lookahead (?!^).
Then the regular expression looks like:
var str = '$hello$ should not be selected but',
str1 = 'not hello but all of the $hello$ and $hello$ ... $hello$
each one ';
str1.match(/(?!^)\$hello\$/g); //["$hello$", "$hello$", "$hello$"]
More information about the Python-list