[ACCEPTED]-Regex to match not start of line-regex
Most likely you can do this using lookbehind:
/(?<!^)</
see: http://www.regular-expressions.info/lookaround.html
0
[^<]+
= one or more characters that are not <
<
= the 1 < you're looking for
replace:
([^<]+)<
with:
$1<
The dot '.' means "any value"
.<
Anyway, I suppose 1 you don't want whitespaces, either. If so, then
\S\s*<
This would give you "<" after the first 1 instance:
[^<]<
Try this:
(?<="[^"]*)<(?=[^"]*")
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(/(?!^)</, '<')
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.