Fernando
Fernando

Reputation: 31

Regex to remove the first two characters of a string

I want to remove the first two characters from a string using Regular expression. The string length is not fixed and can be any number of characters.

EX : FIELD 1 = FERNANDO --> REGEX --> Expected value in FIELD 2 should be FIELD 2 = RNANDO

Have tried this on destination field (?<=[.!?])\s[A-Z], but nothing happens once I enter the value in the source field.

Upvotes: 1

Views: 13780

Answers (1)

Tim Biegeleisen
Tim Biegeleisen

Reputation: 521389

If you are using a programming language here, then most likely you don't/should not need to even use regex. Just take a substring, e.g. in Java:

String input = "FERNANDO";
String output = input.substring(2);  // same call for JavaScript

If you wanted to use a regex replacement approach, you could match the following:

^.{1,2}

and then replace with empty string, to remove the first one or two characters. Or, for a pure regex approach, try matching on:

(?<=^..).*$

Upvotes: 2

Related Questions