0

I have a very big source file, we lines like this:

force `RX_PHY_HIER.rxtriggeresc_0                     = test_vector[310:307]    ;
force `RX_PHY_HIER.rxtriggeresc_1                     = test_vector[314:311]    ;
force `RX_PHY_HIER.rxtriggeresc_2                     = test_vector[318:315]    ;
force `RX_PHY_HIER.rxtriggeresc_3                     = test_vector[322:319]    ;

What I need is to change that into:

force `RX_PHY_HIER.rxtriggeresc_0                     = test_vector[310:307]    ;
force `RX_PHY_HIER.rxtriggeresc_1                     = test_vector[314:311]    ;
`ifdef THREELANES
    force `RX_PHY_HIER.rxtriggeresc_2                     = test_vector[318:315]    ;
`ifdef FOURLANES
    force `RX_PHY_HIER.rxtriggeresc_3                     = test_vector[322:319]    ;
`endif
`endif

I mean, I need to encapsulate all the lines with _2 and _3.

I have thousands of these in my code, so I think I need to use a regular expression.

I can select the whole line containing _2 using ^._2.$ but what I don't know, is to replace one into into the selected line plus a new one(below or above).

Can you please help me?

Condor
  • 59
  • 9
  • Looks like you are looking to create a regex, but do not know where to get started. Please check [Reference - What does this regex mean](https://stackoverflow.com/questions/22937618) resource, it has plenty of hints. Also, refer to [Learning Regular Expressions](https://stackoverflow.com/questions/4736) post for some basic regex info. Once you get some expression ready and still have issues with the solution, please edit the question with the latest details and we'll be glad to help you fix the problem. – Wiktor Stribiżew Mar 20 '20 at 13:02
  • See also [Why is “Can someone help me?” not an actual question?](https://meta.stackoverflow.com/questions/284236) – Wiktor Stribiżew Mar 20 '20 at 13:02

0 Answers0