Regular match paragraphs that have begun and ended with-

clipboard.png

find a match to admin:123456@192.168.14.36/sub that begins / / ends with-
and 192.168.14.36

that begins / ends with @.

the regular expression I wrote myself always returns as false....

.
May.02,2022

/(?<=\/\/).*(?=-)/g;
/(?<=@).*(?=\/)/g;

the first / /. * -, and then add the escape character\ /. *-

the second @. * /, and then add the escape character @. *\ /

clipboard.png

after reading the rules you wrote, you got the meaning of ^ wrong. ^ means to match the beginning of a line, or what the line begins with.
you understand it as the beginning of the string to match. This is wrong

.
var str = 'rtsp://admin:123456@192.168.14.36/sub-1';
var reg = /\/\/(.+-)/;
var matches = str.match(reg);
var result = matches[1];

/\ / (. + (?: (?) /;
/\ @ (. + (?: (? =\ /) /;

Menu