Display text after equal sign with regular expression?

I would like to know if there is code preferred by Regexp that can get all the text after the equal sign.

For instance:

3 + 4 = 7

Results:

7

Is it possible? Hope thanks, thanks in advance.

+4
source share
2 answers
var s = "3+4=7"; var regex = /=(.+)/; // match '=' and capture everything that follows var matches = s.match(regex); if (matches) { var match = matches[1]; // captured group, in this case, '7' document.write(match); } 

Working example in jsfiddle .

+6
source

/=(.*)/ should be enough, since it will find the result on the first =.

Other features (can be transcribed into languages ​​other than Perl)

 $x = "foo=bar"; print "$'" if $x =~ /(?<==)/; # $' = that after the matched string print "$&" if $x =~ /(?<==).*/; # $& = that which matched print "$1" if $x =~ /=(.*)/; # first suggestion from above 
0
source

Source: https://habr.com/ru/post/1386628/


All Articles