Capture Groups with RegEx - Only Capturing First Line

The goal of my macro is to copy a list and use regex to sort out the items from the quantities, then to paste them one at a time, hitting enter each time to paste more information. I receive these lists in a number of different formats, so my regex expression and my example string is trying to account for that.

I have my regex expression working here:

However, when I then type out the variables, I only get the first line.

I'd like it to output the same capture groups as shown in the regex101 link with line breaks after each one.

Would appreciate the help! Let me know if there's anymore info I can provide.

Equipment List Entry copy Macro (v9.0.5)
OS: 10.14.6

Equipment List Entry copy.kmmacros (5.9 KB)

Is there a reason this data needs to be pasted manually? Because it looks like you can put it all on separate lines and paste it all at once with a single search and replace action:

Example Macro.kmmacros (1.6 KB)

Running that macro on the text in your regex.101 example:

5 - 800w Jokers
12 - 25' Stingers
5) 25' Stingers
12-25'Stingers
5)25' Stingers
5 25' Stingers

gives me

800w Jokers
5
25' Stingers
12
25' Stingers
5
25'Stingers
12
25' Stingers
5
25' Stingers
5
1 Like

The reason it has to be pasted manually is because I'm getting these lists in from people who have different names for our equipment than we do. This way I can manually search for each one and find it in our system, then input the quantity, then move onto the next item.

But! I think you helped me solve my problem. I had intially been trying to do this with a search and replace, but I was trying $1 $2 instead of \1 \2. I ended up changing my macro so that I just make one variable that is the full list, then I use that variable in the bottom action. That allows me to enter the item, then the quantity separately each time I hit enter.

Appreciate it!

1 Like