Use the $
metacharacter to match the end of a string.
In Perl, this looks like:
my $str="red/white/blue";
my($last_match) = $str =~ m/.*\/(.*)$/;
Written in JavaScript, this looks like:
var str="red/white/blue".match(/.*\/(.*)$/);
More Related Contents:
- Javascript Array – Split string at numbers [closed]
- Why do regex constructors need to be double escaped?
- How can I match overlapping strings with regex?
- Converting user input string to regular expression
- Javascript RegExp + Word boundaries + unicode characters
- How to escape regular expression special characters using javascript? [duplicate]
- Regular Expression for password validation
- Recursive matching with regular expressions in Javascript
- How to find indices of all occurrences of one string in another in JavaScript?
- Converting any string into camel case
- Differences between Javascript regexp literal and constructor
- Return positions of a regex match() in Javascript?
- How to split a long regular expression into multiple lines in JavaScript?
- How to pull the file name from a url using javascript/jquery?
- JavaScript regular expression for Unicode emoji
- How to extract base URL from a string in JavaScript?
- Strange JavaScript idiom – what does “/xyz/.test(function(){xyz;})” do?
- Regular Expression For Arabic Language
- grunt (minimatch/glob) folder exclusion
- JavaScript regex – How to wrap matches with tag?
- Difference between ?:, ?! and ?=
- Javascript split regex question
- Split a string based on multiple delimiters
- Emulating SQL LIKE in JavaScript
- How can I match on, but exclude a regex pattern?
- Include Arabic characters in JavaScript regular expression?
- What does the “Nothing to repeat” error mean when using a regex in javascript?
- Is there a way to measure string similarity in Google BigQuery
- Use RegExp to match a parenthetical number then increment it
- Regex – Repeating Capturing Group