0

I'm trying to match (extract) any character/symbol at the 3rd position of a string using regex. And no, I can't use substrings for this scenario. Below are examples I want matched:

ABCDEF => C
123456 => 3
A B C  => B

I'm also being guaranteed to have a string of more than 10 characters so I don't have to worry about being less that 3 characters.

Any help would be appreciated.

Los Morales
  • 2,061
  • 7
  • 26
  • 42

1 Answers1

1

You may use this regex with a negative lookbehind:

(?<=^..).

RegEx Demo

RegEx Details:

  • (?<=^..): Lookbehind assertion to match any 2 characters at line start
  • .: Match character at 3rd position
anubhava
  • 761,203
  • 64
  • 569
  • 643