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.
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 .
/=(.*)/ 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
Source: https://habr.com/ru/post/1386628/More articles:primeFaces: fileUpload to byte [] - formsWhat does it mean to say that an interface is also a type? - javaTomcat JSP / JSTL without HTTP - javaSource Code Location for System.Web.Razor.dll - c #How to check all checkboxes in a form application programmatically? - c ++Violation of the rules for sending messages - javaCorrupted $ _GET variable - phpProgramming Tips - objectUsing Clickonce Application and File Handler - c #Is it possible to make a window with a transparent background? - javaAll Articles