Tommy February 2016

How to delete n characters from string with regex

I try to use regex to delete the last n characters from a string. For example:

My input: azerty
My expected Output: azer

I want to have a regular expression that does this.

Answers


RAnders00 February 2016

You want to use this regular expression (try and view an explanation it online):

.{2}$

Post Status

Asked in February 2016
Viewed 3,069 times
Voted 12
Answered 1 times

Search




Leave an answer