With regex, how can I match everything after and including the last occurence of an empty space/tab?
For example, 1283128318231283128213 123881213 81328 ajdh suu
should match suu
Thanks, this is for JavaScript
With regex, how can I match everything after and including the last occurence of an empty space/tab?
For example, 1283128318231283128213 123881213 81328 ajdh suu
should match suu
Thanks, this is for JavaScript
Try this out:
\s[^\s]+$
Follow link below to see it in action with the test data you provided in your question.
Use \s
to match a tab or a white-space character. Since your input won't contain any newline character, you may free to use the below regex.
> "1283128318231283128213 123881213 81328 ajdh suu".match(/\s\S*$/)[0]
' suu'
Update:
> "PRICE $153.00 $133.05 ".match(/\s\S*/)[0].replace(/\D/g, "")
'15300'
Try this:
var re = /^(.*)( |\t)(.*)$/;
var str = "foo bar";
var newstr= str.replace(re, "$3");
console.log(newstr);
var strTwo= "foo bar";
var newstrTwo = strTwo.replace(re, "$3");
console.log(newstrTwo);