[ACCEPTED]-Regex to match not start of line-regex

Accepted answer
Score: 32

Most likely you can do this using lookbehind:

/(?<!^)</

see: http://www.regular-expressions.info/lookaround.html

0

Score: 8

[^<]+ = one or more characters that are not <

< = the 1 < you're looking for

replace:

([^<]+)<

with:

$1&lt;
Score: 5

The dot '.' means "any value"

.<

Anyway, I suppose 1 you don't want whitespaces, either. If so, then

\S\s*<
Score: 1

This would give you "<" after the first 1 instance:

[^<]<
Score: 0

Try this:

(?<="[^"]*)<(?=[^"]*")

0

Score: 0

@duncan's method works fine if you just 9 want to replacing, but it doesn't match 8 the <. and all the lookbehind wont work if 7 you a using javascript. because javascript 6 doesn't support lookbehind, unless you turn 5 on the --harmony flag in nodejs or experimental javascript 4 features in chrome. But lookahead will work 3 here, which is: /(?!^)</ will match the < which is 2 not at the begining of a line. and the replacing 1 will be: '<list message="2 < 3">'.replace(/(?!^)</, '&lt;')

More Related questions