This piece of regex (?<=href\=")[^]+?(?=#_)must match all href values except the hash value and what follows in the href url. It seems to work fine under Regex debuggers / testers such as http://gskinner.com/RegExr/ but in javascript it causes a syntax error. If I remove <from (?<=), it works, however, this is not the positive look I am looking for.
(?<=href\=")[^]+?(?=#_)
<
(?<=)
I pull my hair out as usual thanks to regex lol
Please, help
(?<=...) (?<!...) lookbehinds, lookaheads. Lookbehind Javascript.
(?<=...)
(?<!...)
Lookbehinds , .
, , match(), :
match()
href="(.+?)(?=#)
, :
var str = '<a href="foo#bar"></a>'; var matches = str.match(/href="(.+?)(?=#)/); // matches[0] = href="foo // matches[1] = foo // <-- this is what you want
:
[^] , . . , , ..
[^]
.
, RegExr, , RegExr - Flash-, ActionScript, JavaScript. AS EcmaScript , JS, . PCRE, , PHP.
, JavaScript- , , JavaScript, .
Source: https://habr.com/ru/post/1747882/More articles:jQuery - Multiple selectors and multiple values in an ONE call - optimizationЭто правильный способ вставить текст в курсор в Android? - androidНедопустимый аргумент в файле sendfile() с двумя обычными файлами - cразвертывание WAMP → живого сайта - любые случайные подсказки? - securityJUnit error - complaints about missing data that was just inserted - javaРазделить длинную строку на массив более коротких строк - c#How to convert "é" to é in php? - phpUsing the list of links in system programming - cCakePHP ROOT Constant Constant - phppython sqlite3 will not make the connection, but only sqlite3 will be - pythonAll Articles