Extracting Field 2 of Pipe-Delimited Text

If the data after the first pipe is always a series of one or more digits, then you could simplify with:

^.*?\|\h*(\d+).*
image

No need to trim.

This also:

  • Allows for null (nothing) before the first pipe.
  • Allows for any amount of horizontal whitespace (including none) after the first pipe.

For details, paste the RegEx pattern and example data into Regex101.com

1 Like