Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to access multiple capture groups in AUTOINST REGEXP? #1662

Closed
veripoolbot opened this issue Jan 27, 2020 · 3 comments
Closed

How to access multiple capture groups in AUTOINST REGEXP? #1662

veripoolbot opened this issue Jan 27, 2020 · 3 comments

Comments

@veripoolbot
Copy link
Collaborator

@veripoolbot veripoolbot commented Jan 27, 2020


Author Name: Shareef Jalloq
Original Redmine Issue: 1662 from https://www.veripool.org


Hi,

I'm wanting to pull out a number of terms from an AUTOINST regexp but can't find an example. If I have two module instance names of "u_tx0" and "u_tx1" with a regext of "_(tx([0-9]))", I'm expecting to see two capture groups. The first would have the full "tx0" or "tx1" ; the second "0" and "1".

How do I access the second capture group? The documentation/manual talks about using multiple groups but only gives the example of using @ to get the first group.

Shareef.

@veripoolbot

This comment has been minimized.

Copy link
Collaborator Author

@veripoolbot veripoolbot commented Jan 27, 2020


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2020-01-27T12:03:24Z


Use backslash 1, 2, 3 etc. Please see https://github.com/veripool/verilog-mode/blob/master/FAQ.adoc#how-do-i-use-auto_template-to-match-multiple-port-names

@veripoolbot

This comment has been minimized.

Copy link
Collaborator Author

@veripoolbot veripoolbot commented Jan 27, 2020


Original Redmine Comment
Author Name: Shareef Jalloq
Original Date: 2020-01-27T12:30:14Z


What about in the instance name rather than the ports? Or what happens if I have two lots of regex?

/* mymodule AUTO_TEMPLATE "\(tx\([0-9]+\)\)"
.\(CTRL[0-9]+\) (@_\1[X]),
); */

In the above example, I want to replace X with the second capture group from the instance name.

I want the following:


mymodule
  u_tx5 (.CTRL0 (tx5_CTRL0[5]));

@veripoolbot

This comment has been minimized.

Copy link
Collaborator Author

@veripoolbot veripoolbot commented Jan 27, 2020


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2020-01-27T13:17:43Z


Sorry, thought you were referring to a template of a AUTOINST. The cell name regexp attached to the AUTOINST itself only uses \1 as @. For anything else you need lisp code using vl-cell, see https://github.com/veripool/verilog-mode/blob/master/FAQ.adoc#how-do-i-have-auto_template-use-the-second-number-in-a-instance-name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.