Help with a Regex Pattern for extract value on different lines


I am using this string below, each line is a separate line and I am trying to extract ‘Carrier’ and ‘NP’ from it. I have been trying to find a way to do it with Regex but can’t seem to get and looking for some help, thank you.

Bus. Unit/Subgroup Program Carrier DIRECT (bill to contracts) *Bill Format 2 Premium Key
1000 RP NP COMMERCIAL (bill to Grp/Cls or Subgroup) X *AC Code *AC Code


Welcome to forums

Check as below, Do you mean like below

If not then let me know more like providing expected output


@Trevor_Sorel - Please provide few more sample texts , based on that I will provide the Regex Patterns…

1 Like

Hey @Trevor_Sorel

Please provide:

  • a few samples,
  • the expected output (you can bold the text) and
  • information on the pattern (what’s consistent)

You will have a robust regex pattern very fast (within minutes not hours) once you do this.


I have not been to get a sample together. I have tried positive lookaheads and things of that nature.

The desired output is ‘Carrier NP’. Carrier is constant value, where NP can very from different two character.

I did however find a simple soultion to my issue where I use - .*COMMERCIAL. This will give everything in front of it and I will some string manipulation to get the value I need.

Hey mate

Check out these Regex Patterns:
Pattern for Carrier
Pattern for NP

If you need it in a workflow, let me know.

Hopefully this helps.

Thanks for those. I use them.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.