Brad Woods
Brad Woods

Reputation: 1546

regex don't capture 1st character

I want to capture every letter except the first letter in the string.
Example string: The cat in the hat.

I know to capture the first letter is /[^]/ so I would want something like /not [^]/

Upvotes: 2

Views: 2009

Answers (2)

hwnd
hwnd

Reputation: 70722

You can utilize a capture group with a basic regular expression.

^.(.*)

The capture group stores the match result ignoring the first character in the string.

Demo

Upvotes: 1

heemayl
heemayl

Reputation: 41987

Use a zero width positive lookbehind:

(?<=^.).*

Demo

Upvotes: 7

Related Questions