Link to home
Start Free TrialLog in
Avatar of hankknight
hankknightFlag for Canada

asked on

JavaScript: Remove everything after certain characters

Using  JavaScript, how can I remove everything after the last one of these characters?
.  ?  '  !  "  


var str = 'This is a test.  It is a'; // should become: This is a test.
var str = 'This is a test!  Hello'; // should become: This is a test!
var str = 'This is a "test."  123'; // should become: This is a "test."

Open in new window

SOLUTION
Avatar of StingRaY
StingRaY
Flag of Thailand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of Roonaan
Roonaan
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial