I am trying to identify the characters between the last space character and the end of a line.
Input: "this and that" Output: "that"
I tried the regex below, but it doesn't work!
var regex = /[\s]$/
You can do without regex
var result = string.substring(string.lastIndexOf(" ")+1);
Using regex
result = string.match(/\s[az]+$/i)[0].trim();
I suggest you use a simple regex pattern
\S+$
document.writeln("this and that".match(/\S+$/));
that
Check here .
You can simply delete everything to the last place.
s.replace(/.* /, '')
Or, to match any space ...
s.replace(/.*\s/, '')
In your example, there is only one space at the end of the line. Use
/\s\S+$/
to match any number.
Source: https://habr.com/ru/post/1442514/More articles:Firemonkey Mac Update Web Application - delphihttps://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1442510/jquery-binding-functions-to-objects-in-array-avoiding-closure-mistakes&usg=ALkJrhjvxXWcZUi8-mGImrD0VhpzffCBKwUnexpected behavior of memset () - c ++jQuery: function for binding objects in for-loop with latching fix - javascriptC # Coding Code - c #Android progheider nightmare - androidPhonegap contact.save duplicate phoneNumbers when updating a contact - javascriptWhat does the document ["Some Name"] really do? - javascriptFiltering an object in SQLAlchemy - pythonIs there any sample Java code that encrypts AES just like this site? - javaAll Articles